-
-
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
Monkeypatching "compile" breaks pytest sometimes #1985
Comments
Hey @suranap, Unfortunately the code which generates the traceback representation calls What happens if you call it with |
Unfortunately my version of
|
Oops sorry I meant
|
its an expected breakage, the ast is used to find statement ranges and statements if you monkey-patch compile, just leave the ast making intact we should decide if we want to proof py.test against that kind of usage |
Would it be possible to use the
IMHO pytest shouldn't go through hoops to support monkey-patching builtins like Having said that I wouldn't be opposed to accept a PR that replaced the |
last i checked ast calls compile in at least one supported python version |
I ran it with When does monkeypatch undo it's patching? Should it undo before it processes the traceback? That feels like the safer operation. Undo any nonsense the user may have done before running pytest's code. |
fixture teardown (and undo) happens after making reports i think its perfectly fine to fall over if people "steal our feet" |
closing as footguns are footguns after all |
* Add note about not monkey-patching builtins Related to #1985 * Mention -s as well
Thanks for submitting an issue!
Here's a quick checklist in what to include:
We use the builtin
compile
function to process Python code at runtime. I wrote a unit test that replacedcompile
with a function that raises many different types of exceptions. Curiously, some of those exceptions caused an INTERNALERROR in pytest. I don't know what's happening, but it appears monkeypatch is replacingcompile
when pytest is trying to use it. This is strange, because monkeypatch shouldn't be called until the unit test executes.pip list
of the virtual environment you are using$ py.test --version This is pytest version 3.0.3, imported from /Users/surana/Projects/tmp/pytesting/lib/python3.5/site-packages/pytest.py
The text was updated successfully, but these errors were encountered: