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

capsys not capturing on Python 2.7 #2327

Closed
cjw296 opened this issue Mar 23, 2017 · 6 comments
Closed

capsys not capturing on Python 2.7 #2327

cjw296 opened this issue Mar 23, 2017 · 6 comments
Labels
plugin: capture related to the capture builtin plugin plugin: unittest related to the unittest integration builtin plugin type: bug problem that needs to be addressed

Comments

@cjw296
Copy link

cjw296 commented Mar 23, 2017

This works on 3.5:

https://travis-ci.org/cjw296/sybil/jobs/214145869

But on 2.7, the capsys is empty:

https://travis-ci.org/cjw296/sybil/jobs/214145867#L301
https://travis-ci.org/cjw296/sybil/jobs/214145867#L314

@cjw296
Copy link
Author

cjw296 commented Mar 24, 2017

Well, this is the diff that got things working:

simplistix/sybil@d6cf19a

My guess is that unittest in py2.7 is doing something that makes capsys sad. Probably not worth bottoming out...

@cjw296 cjw296 closed this as completed Mar 24, 2017
@cjw296
Copy link
Author

cjw296 commented Mar 24, 2017

nb: test_nose below the test I updated, that uses capsys and works fine...

@RonnyPfannschmidt
Copy link
Member

thansk for the followup

@cjw296
Copy link
Author

cjw296 commented Mar 24, 2017

@RonnyPfannschmidt - weirder still, this also works: simplistix/sybil@791fe74

...and here we have it:
https://hg.python.org/cpython/file/v2.7.11/Lib/unittest/runner.py#l127

d'oh.

I thought a -c fd would work with that? It didn't...

@RonnyPfannschmidt
Copy link
Member

Import time sys.stdout differs from test time sys.stdout

This is a bug in unittest, but pytest should protect you against it

@asottile
Copy link
Member

asottile commented Jun 2, 2020

hello, first off thank you for the issue!

python 2.x support has ended for pytest core.

we've decided in #7296 to close the python-2-specific issues to free up some space in our backlog. however, in accordance to our python 2.7 and 3.4 support community patches will still be accepted to the 4.6 series to fix bugs for python 2. (so if this issue is important to you and you have a patch to fix it, feel free to make a PR targeting the 4.6.x branch despite this ticket being closed).

@asottile asottile closed this as completed Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: capture related to the capture builtin plugin plugin: unittest related to the unittest integration builtin plugin type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

5 participants