I'm not sure if this is related to
http://groups.google.com/group/pylons-discuss/browse_thread/thread/a8e616774a381b2e/e5c7edddefcd43b1?lnk=gst&q=TypeError#e5c7edddefcd43b1
or not.
I'm using Pylons 0.9.7 installed in a no-site-packages virtualenv with
Python 2.5.
I'm seeing a TypeError exception from WebOb when I call abort(404)
with the details argument set to anything other than the default empty
string. Oddly, the exception only occurs in the test environment *not*
in the browser.
Any insights welcome...
************* Test ****************
def test_DN_view_or_edit_no_such_form(self):
"""GET request for non-existent DN fails with 404
"""
self.app.get(url=url('/DN-10-042'), status=404)
***************** Code under test *********************
try:
form = model.database.get(
'DN-%(year)s-%(number)s' % vars(),
wrapper=model.DN.wrap)
except couchdb.ResourceNotFound:
abort(404)
**************** Traceback *****************************
ERROR: GET request for non-existent DN fails with 404
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/pylons_env/Minerva-dev/minerva/tests/functional/
test_DN.py", line 92, in test_DN_view_or_edit_no_such_form
self.app.get(url=url('/DN-10-042'), status=404)
File "/var/pylons_env/lib/python2.5/site-packages/webtest/
__init__.py", line 153, in get
expect_errors=expect_errors)
File "/var/pylons_env/lib/python2.5/site-packages/webtest/
__init__.py", line 310, in do_request
res = req.get_response(app, catch_exc_info=True)
File "/var/pylons_env/lib/python2.5/site-packages/webob/request.py",
line 914, in get_response
application, catch_exc_info=True)
File "/var/pylons_env/lib/python2.5/site-packages/webob/request.py",
line 886, in call_application
app_iter = application(self.environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/webtest/lint.py",
line 170, in lint_app
iterator = application(environ, start_response_wrapper)
File "/var/pylons_env/lib/python2.5/site-packages/paste/cascade.py",
line 130, in __call__
return self.apps[-1](environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/paste/
registry.py", line 350, in __call__
app_iter = self.application(environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/pylons/
middleware.py", line 201, in __call__
self.app, environ, catch_exc_info=True)
File "/var/pylons_env/lib/python2.5/site-packages/pylons/util.py",
line 94, in call_wsgi_application
app_iter = application(environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/weberror/
evalexception.py", line 235, in __call__
return self.respond(environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/weberror/
evalexception.py", line 418, in respond
return self.application(environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/beaker/
middleware.py", line 73, in __call__
return self.app(environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/beaker/
middleware.py", line 152, in __call__
return self.wrap_app(environ, session_start_response)
File "/var/pylons_env/lib/python2.5/site-packages/routes/
middleware.py", line 130, in __call__
response = self.app(environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/pylons/
wsgiapp.py", line 125, in __call__
response = self.dispatch(controller, environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/pylons/
wsgiapp.py", line 324, in dispatch
return controller(environ, start_response)
File "/var/pylons_env/Minerva-dev/minerva/lib/base.py", line 32, in
__call__
return WSGIController.__call__(self, environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/pylons/controllers/
core.py", line 284, in __call__
return response(environ, self.start_response)
File "/var/pylons_env/lib/python2.5/site-packages/webob/exc.py",
line 248, in __call__
return self.generate_response(environ, start_response)
File "/var/pylons_env/lib/python2.5/site-packages/webob/exc.py",
line 239, in generate_response
content_type=content_type
File "/var/pylons_env/lib/python2.5/site-packages/webob/
response.py", line 94, in __init__
"You cannot set the body to a unicode value without a charset")
TypeError: You cannot set the body to a unicode value without a
charset
********************************************
Changing the code under test to:
try:
form = model.database.get(
'DN-%(year)s-%(number)s' % vars(),
wrapper=model.DN.wrap)
except couchdb.ResourceNotFound:
if request.environ['paste.testing']:
abort(404)
else:
abort(404, 'DN-%(year)s-%(number)s does not exist' %
vars())
make the test pass.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.