-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Importing files during tests fails with patched open builtin #2180
Comments
The I'm not really sure if there's much pytest can do about this though... |
@The-Compiler that makes total sense. However, what bugs me is that this used to work with nosetests, so i am now wondering what pytest's import machinery is doing that nost wasn't. Any ideas? |
Yes - using |
@rakanalh to add to what @The-Compiler said: it uses If you don't want to change your test, you can use Also, i wonder if we should be able to somehow "mark" (not in the context of a |
i wonder if we should just import |
That sounds like a good idea to me. We also should check which other builtins are used, and import those as well. If that fixes most problems we've seen caused by patched builtins, we might not even need #2203 after all. |
Closing this because contrary to what was discussed here, the error happens inside |
Hello,
When using PyTest to run a python unittest, PyTest fails at some tests that patch
builtins.open
.Basically the use-case is that i am trying to test a function which would call Consul to read some configuration value and then validate some JSON file. When the configuration value is being read through python-consul which in turn makes a call through requests, the failure takes place.
Python Version: 3.5.2
Package Versions:
Running MacOS Sierra, but i've also been able to reproduce this inside a debian docker image:
I've written a small script which can reproduce the issue:
The full stacktrace:
Here's a quick checklist in what to include:
pip list
of the virtual environment you are usingThe text was updated successfully, but these errors were encountered: