You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Seems WebOb 1.7 has some glitches with WebTest when a 204 is responded #305
The recent WebOb 1.7 changes to initialisation function seem to had introduced a side effect when WebTest is used, as webtest will recreate a new Response object from the application response.
A simple testcase can be created to showcase the issue:
from webob import Response
def wsgi_app(environ, start_response):
resp = Response(status='204 No Content', body=b'')
resp.content_type = None
return resp(environ, start_response)
The snippet is meant to work on both 1.6 and 1.7, so it adds some unnecessary values like body and content_type which are already provided in 1.7 (those values are in fact a nop on 1.7) while they are required on 1.6 to generate a response without content.
The response is as expected both on 1.6 and 1.7
Response: 204 No Content
Creating a plain webtest TestApp from the previous example:
from webtest import TestApp
app = TestApp(wsgi_app)
app.get('/')
will issue a validation error on WebOb 1.7:
Iterator garbage collected without being closedException AssertionError: AssertionError('Iterator garbage collected without being closed',) in <bound method IteratorWrapper.__del__ of <webtest.lint.IteratorWrapper object at 0x100ed0850>> ignored
while it will work without the error with WebOb 1.6.
I wouldn't take for granted that if there is an app_iter it will be wrong and needs to be discarded as response has no content. It's probably a right assumption in the case of body, but discarding app_iter might in fact break some application by discarding an iterator which returns an empty response too but has other side effects.
It may be that if there is an app_iter provided that we set it explicitly, and let the user deal with the breakage if their app_iter contains data and it shouldn't.
Activity
digitalresistor commentedon Jan 9, 2017
Thanks for the report @amol-
It may be that if there is an
app_iterprovided that we set it explicitly, and let the user deal with the breakage if theirapp_itercontains data and it shouldn't.Add tests that showcase #305
Add tests that showcase #305
Add tests that showcase #305
Add CHANGES.txt for #305 fix
digitalresistor commentedon Jan 17, 2017
I have added a test and
app_iteris now set onResponse. New release is out: https://pypi.python.org/pypi/WebOb/1.7.1