test failure output is duplicated/triplicated

Bug #1378609 reported by Richard Jones
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
testtools
Fix Released
Critical
Robert Collins

Bug Description

When running "tox -e py27" in the oslo.middleware project, and forcing one of the tests to fail, the following is observed:

======================================================================
FAIL: tests.test_cors.CORSMiddlewareTest.test_add_headers
tags: worker-0
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/richard/src/openstack/oslo.middleware/tests/test_cors.py", line 45, in test_add_headers
    FAIL
NameError: global name 'FAIL' is not defined
Traceback (most recent call last):
_StringException: Empty attachments:
  stderr
  stdout

Traceback (most recent call last):
  File "/Users/richard/src/openstack/oslo.middleware/tests/test_cors.py", line 45, in test_add_headers
    FAIL
NameError: global name 'FAIL' is not defined

Traceback (most recent call last):
_StringException: Empty attachments:
  stderr
  stdout

Traceback (most recent call last):
  File "/Users/richard/src/openstack/oslo.middleware/tests/test_cors.py", line 45, in test_add_headers
    FAIL
NameError: global name 'FAIL' is not defined
Ran 18 tests in 0.033s (-0.003s)
FAILED (id=86, failures=1 (+1))
error: testr failed (1)
ERROR: InvocationError: '/Users/richard/src/openstack/oslo.middleware/.tox/py27/bin/python setup.py testr --slowest --testr-args='

Also, the "Traceback..._StringException..." parts of the ouput are just noise as far as I can tell.

Revision history for this message
Dan Smith (danms) wrote :

Note that this also affects the openstack-nova project

Revision history for this message
Robert Collins (lifeless) wrote :

Does this happen in a vanilla test suite? I know there are a bunch of adapters in oslo that play around with stdout etc that might interact to cause this.

Changed in testrepository:
status: New → Incomplete
Revision history for this message
Matthew Treinish (treinish) wrote :

Here are 2 simple ways to reproduce the issue:

http://paste.openstack.org/show/166475/

and

http://paste.openstack.org/show/166477/

Revision history for this message
Clark Boylan (cboylan) wrote :

I think the logging fixture uses the StringStream fixture under the hood and just making a StringStream fixture appears to be sufficient to create the behavior.

Revision history for this message
Robert Collins (lifeless) wrote :

Thanks, I shall investigate.

Changed in testrepository:
status: Incomplete → Confirmed
Revision history for this message
Robert Collins (lifeless) wrote :

Wow two very different reproducers. The first one works with subunit.run, eliminating testrepository as a cause.

affects: testrepository → trv
affects: trv → subunit
Revision history for this message
Robert Collins (lifeless) wrote :

Ug well thats special. Empty pythonlogging attachment is triggering a TypeError in the subunit status -> bytes code, and thats caught by the fallback code for APIs in testtools, triggering a conversion to to a pretend exception. This explains 2 copies.

Revision history for this message
Robert Collins (lifeless) wrote :

The conversion then fails identically, giving:
"TypeError: "cannot concatenate 'str' and 'NoneType' objects""

That then bubbles up to a second level of fallback code explaining the third copy.

Revision history for this message
Robert Collins (lifeless) wrote :

bug is in this code in testtools:
1344 file_bytes = None
1345 for next_bytes in content.iter_bytes():
1346 if file_bytes is not None:
(Pdb)
1347 self.status(file_name=name, file_bytes=file_bytes,
1348 mime_type=mime_type, test_id=test_id, timestamp=now)
1349 file_bytes = next_bytes
1350 self.status(file_name=name, file_bytes=file_bytes, eof=True,
1351 -> mime_type=mime_type, test_id=test_id, timestamp=now)

affects: subunit → testtools
Revision history for this message
Robert Collins (lifeless) wrote :
Changed in testtools:
importance: Undecided → Critical
status: Confirmed → Triaged
assignee: nobody → Robert Collins (lifeless)
Changed in testtools:
status: Triaged → Fix Committed
milestone: none → next
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.