Skip to content

Commit

Permalink
Fix running nose with xunit.
Browse files Browse the repository at this point in the history
When running nosetest with xunit, the tests would crash for external
projects using python 3.5 with something similar to:

Traceback (most recent call last):
  File "./lib/python3.5/site-packages/luigi/mock.py",
  line 128, in write
      stderrbytes = sys.stderr.buffer
      AttributeError: 'Tee' object has no attribute 'buffer'

This is becuase xunit overrides sys.stderr, and the class it uses does
not have a 'buffer' attribute.

Nose source:
  https://github.com/nose-devs/nose/blob/master/nose/plugins/xunit.py#L127-L147
  • Loading branch information
KyleJamesWalker committed Apr 19, 2016
1 parent 8d39715 commit 163991d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions luigi/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,10 @@ def set_wrapper(self, wrapper):
self.wrapper = wrapper

def write(self, data):
if six.PY3:
stderrbytes = sys.stderr.buffer
else:
stderrbytes = sys.stderr

if mock_target._mirror_on_stderr:
if self._write_line:
sys.stderr.write(fn + ": ")
stderrbytes.write(data)
sys.stderr.write(data)
if (data[-1]) == '\n':
self._write_line = True
else:
Expand Down

0 comments on commit 163991d

Please sign in to comment.