Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running nose with xunit. #1659

Merged
merged 1 commit into from
Apr 21, 2016
Merged

Conversation

KyleJamesWalker
Copy link
Contributor

Description

When running nosetest with xunit on projects that use luigi (nosetests tests --with-xunit), the tests would crash for external 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 because xunit overrides sys.stderr, and the class it uses does
not have the 'buffer' attribute defined.

Nose source:
https://github.com/nose-devs/nose/blob/master/nose/plugins/xunit.py#L127-L147

Motivation and Context

I can't run unit tests with xunit output, on my person projects.

Have you tested this? If so, how?

I have run the existing unit tests in test_mock.py for python 3.5 and 2.7. Also having this fix in my project passes all existing unit tests.

Note: The original commit that added this is here if needed: 21f42bc

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @gpoulin, @erikbern and @steenzout to be potential reviewers

@Tarrasch
Copy link
Contributor

Thanks! Though there seem to be test case failure. If you can make this run on Travis too we'll definitely merge. :)

(thanks for very nice PR description :))

@KyleJamesWalker
Copy link
Contributor Author

KyleJamesWalker commented Apr 20, 2016

I'll take a look ASAP

Edit: Think I got it, running the ALL tests to verify with 27 and 35

stderrbytes = sys.stderr.buffer
else:
stderrbytes = sys.stderr

if mock_target._mirror_on_stderr:
if self._write_line:
sys.stderr.write(fn + ": ")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Why was this not originally not using stderrbytes?

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
@KyleJamesWalker
Copy link
Contributor Author

@Tarrasch I think this should fix it, let me know if it looks alright to you (once all the tests finish of course)

@Tarrasch Tarrasch merged commit a3fe817 into spotify:master Apr 21, 2016
This was referenced Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants