-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
pytest assumes stdout implements isatty() #5462
Comments
I'm not sure |
Is pytest 4.6 supported on python 2? |
it is, but given it was removed from the python3 docs I'm not sure it's important to fix for python2 either |
Well, Maya 2018 is python 2 and afaik its implementation of stdout meets the requirements of python 2. |
@bernardlebel would you like to contribute a patch? I would love to review and merge this fix into the |
Hello there, As a quick fix i changed the lines 248 in _pytest\terminal.py
I can use pytest now(without the capture things, because fds 0,1,2 are not openable on this software...) Would this be an appropriate fix for pytest module? P.S. i'm using python3 here, so i think this bug is not only related to python2... |
The bug is in itom, it should implement isatty when monkeypatching standard streams |
Yeah. |
I disagree, I don't think we should intentionally enable broken code -- if |
@blueyed Yes, you're right. catching AttributeError only is the better approach. |
@OliverSchwanke it's not about intention, it's about enabling broken code say I was developing such a thing, I would want to know that I'm implementing a stream incorrectly and if my test runner is lying to me about what's correct I'd be pretty peeved with my test runner I'd much rather send a PR to itom to fix their monkeypatch |
@OliverSchwanke |
PR is done, so itom is working with pytest now. |
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 |
For anyone stumbling upon this looking for a workaround, I ended up writing a small wrapper for sys.stdout. import sys
class StdOutWrapper:
def __init__(self, stdout):
self._stdout = stdout
def __getattr__(self, item):
if item == "isatty":
return self.isatty
else:
return getattr(self._stdout, item)
def isatty(self):
return False
sys.stdout = StdOutWrapper(sys.stdout)
sys.stdout._stdout |
* Create python code module * Add python code module to example character * Unit testing for python code module * Fix test runner to handle this weird error. pytest-dev/pytest#5462
Hello there,
TerminalWriter assumes that the sys.stdout object has a isatty() method.
I have read #1447, and I'm not sure that the point about io.IOBase is always true. According to the sys.stdout documentation:
In my case, the sys.stdout object isn't under my control, it's provided by a DCC application (Maya), and it doesn't have that method at all. It's a C object so python doesn't even let me add a method to it.
Here's the traceback I get:
Right now I'm forced to monkey patch the DCC object.
Thanks!
Bernard
The text was updated successfully, but these errors were encountered: