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
Occasionally the gunicorn unit tests fail with an error like this:
======================================================================
FAIL: 012.http: MT: readline SZ: small_random SN: random
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/nose/case.py", line 187, in runTest
self.test(*self.arg)
File "gunicorn-0.13.4/tests/treq.py", line 219, in test_req
self.check(sn, sz, mt)
File "gunicorn-0.13.4/tests/treq.py", line 229, in check
self.same(req, sizer, matcher, cases.pop(0))
File "gunicorn-0.13.4/tests/treq.py", line 244, in same
t.eq(req.trailers, exp.get("trailers", []))
File "gunicorn-0.13.4/tests/t.py", line 85, in eq
assert a == b, "%r != %r" % (a, b)
AssertionError: [] != [('VARY', '*'), ('CONTENT-TYPE', 'text/plain')]
----------------------------------------------------------------------
I eventually narrowed it down to cases where treq.request.size_small_random was returning a sequence like [11, 0, 0]. Actually it could be any sequence which sums to 11, followed by two zeroes. Here is a reproducer:
The test ends up calling req.body.readline(11), which returns the complete request body 'hello world'. It then calls req.body.readline(0), which returns ''. But the test assumes it is finished reading the request, when in fact it is not. So the parser never has a chance to read the trailers, so they come out as an empty list.
I think this is an invalid test, and there's no reason to test calling body.readline(0) at all, because why would anyone do that? Here is a simple patch to stop testing with zero:
Occasionally the gunicorn unit tests fail with an error like this:
I eventually narrowed it down to cases where
treq.request.size_small_random
was returning a sequence like[11, 0, 0]
. Actually it could be any sequence which sums to 11, followed by two zeroes. Here is a reproducer:The test ends up calling
req.body.readline(11)
, which returns the complete request body'hello world'
. It then callsreq.body.readline(0)
, which returns''
. But the test assumes it is finished reading the request, when in fact it is not. So the parser never has a chance to read the trailers, so they come out as an empty list.I think this is an invalid test, and there's no reason to test calling body.readline(0) at all, because why would anyone do that? Here is a simple patch to stop testing with zero:
The text was updated successfully, but these errors were encountered: