-
Notifications
You must be signed in to change notification settings - Fork 91
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
Mock doesn't work after setUpPyfakefs #334
Comments
That's interesting - I could reproduce it. I didn't understand it yet (seems to be some module caching issue), and the obvious workaround is to put such tests into separate files, but I will have another look later. |
Having the test in separate files doesn't help (at least when using a test suite like Nose to run all tests). I created the above example as the simplest reproduction, but I originally discovered the issue from changing one of my tests to use the setUpPyfakefs call, and having tests in another module fail. |
Hm, ok, you are right - this won't help if this a module caching issue. One (ugly) way to avoid this is to import os inside the test - but there has to be a better way. I will probably have another look tomorrow. |
Fixed by @absolutelyNoWarranty in #336. |
Now fixed the root cause (missing cleanup) in #340. |
After I run a
fake_filesystem_unittest.TestCase
with theself.setUpPyfakefs()
method,unittest.mock
doesn't seem to work correctly in subsequent test cases.Here is an example that reproduces the issue:
When the TestFakeFsUnittest runs first, I get:
But if TestMockOsPath runs first (e.g. by renaming TestFakeFsUnittest to be alphabetically after) I get:
The text was updated successfully, but these errors were encountered: