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
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)
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.
The text was updated successfully, but these errors were encountered: