summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-01-21 17:25:19 -0500
committerChris McDonough <chrism@plope.com>2012-01-21 17:25:19 -0500
commit8a36219597ec555c4ed95561ada7e5682a1605f7 (patch)
tree4a86a8079fde1984ccefa14df7796d17dd921cf4
parent0b21fdf557f1b916cd9d9d75e295dece6aa5e717 (diff)
downloadpyramid-8a36219597ec555c4ed95561ada7e5682a1605f7.tar.gz
pyramid-8a36219597ec555c4ed95561ada7e5682a1605f7.tar.bz2
pyramid-8a36219597ec555c4ed95561ada7e5682a1605f7.zip
- The ``prequest`` script would fail when used against URLs which did not
return HTML or text. See https://github.com/Pylons/pyramid/issues/381 Fixes #381.
-rw-r--r--CHANGES.txt3
-rw-r--r--pyramid/scripts/prequest.py5
-rw-r--r--pyramid/tests/test_scripts/test_prequest.py14
3 files changed, 19 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 5f55c7f72..c64ed47e7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,9 @@ Bug Fixes
changed. See https://github.com/Pylons/pyramid/issues/377 and
https://github.com/Pylons/pyramid/pull/411
+- The ``prequest`` script would fail when used against URLs which did not
+ return HTML or text. See https://github.com/Pylons/pyramid/issues/381
+
1.3a6 (2012-01-20)
==================
diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py
index a102dda7e..5423a6316 100644
--- a/pyramid/scripts/prequest.py
+++ b/pyramid/scripts/prequest.py
@@ -140,5 +140,8 @@ class PRequestCommand(object):
self.out(response.status)
for name, value in response.headerlist:
self.out('%s: %s' % (name, value))
- self.out(response.ubody)
+ if response.charset:
+ self.out(response.ubody)
+ else:
+ self.out(response.body)
return 0
diff --git a/pyramid/tests/test_scripts/test_prequest.py b/pyramid/tests/test_scripts/test_prequest.py
index 7f24174ef..cf7af4218 100644
--- a/pyramid/tests/test_scripts/test_prequest.py
+++ b/pyramid/tests/test_scripts/test_prequest.py
@@ -5,9 +5,10 @@ class TestPRequestCommand(unittest.TestCase):
from pyramid.scripts.prequest import PRequestCommand
return PRequestCommand
- def _makeOne(self, argv):
+ def _makeOne(self, argv, headers=None):
cmd = self._getTargetClass()(argv)
cmd.get_app = self.get_app
+ self._headers = headers or []
self._out = []
cmd.out = self.out
return cmd
@@ -18,7 +19,7 @@ class TestPRequestCommand(unittest.TestCase):
def helloworld(environ, start_request):
self._environ = environ
self._path_info = environ['PATH_INFO']
- start_request('200 OK', [])
+ start_request('200 OK', self._headers)
return [b'abc']
return helloworld
@@ -131,6 +132,15 @@ class TestPRequestCommand(unittest.TestCase):
self._out,
['200 OK', 'Content-Type: text/html; charset=UTF-8', 'abc'])
+ def test_command_response_has_no_charset(self):
+ command = self._makeOne(['', '--method=GET', 'development.ini', '/'],
+ headers=[('Content-Type', 'image/jpeg')])
+ command.run()
+ self.assertEqual(self._path_info, '/')
+ self.assertEqual(self._spec, 'development.ini')
+ self.assertEqual(self._app_name, None)
+ self.assertEqual(self._out, [b'abc'])
+
class Test_main(unittest.TestCase):
def _callFUT(self, argv):
from pyramid.scripts.prequest import main