-
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
pathlib.Path is not patched in unittest test fixuture #440
Comments
Thanks for the report! I'm traveling right now, but will have a look at this somewhere next week. |
Ok, first: this is a known shortcoming of pyfakefs described in the documentation - it will not work out of the box, as you probably know. That being said, I think it makes sense to add patching this specific import (e.g. |
@Shredd - it shall work now out of the box in master. Please check if it works for you! |
@mrbean-bremen Pulled master, installed pyfakefs 3.5 locally, and confirmed that this example now passes (ubuntu 16.04, python 3.7.0). Glad to help! For retrospect: Yes the sample that I posted is a known issue and I did see the requirement to use the particular import statement as a workaround (I was not able to use this workaround import statement successfully in testing). Initially I tried setting modules_to_reload and/or modules_to_patch (in varying combinations) as keyword arguments in the call to setUpPyFakefs() however I did not attempt to use the Patcher class for context management. I do not have access to the original code that prompted this (not checked in). |
Ok, thanks - I'm closing the issue in this case. |
Similar to issue #420 however this has been observed with unittest rather than pytest. I did search for workarounds including module patching and reloading however I was not successful in finding a working solution.
pyfakefs==3.4.3
python==3.7.0
On Ubuntu 16.04
Test cases below: the test_Path_exists method demonstrates a test case that should pass but does not pass. The test would pass if pathlib.Path had been successful at interacting with the fake filesystem.
Test output:
Anecdotally, I have experienced the same issue on windows and with other methods from pathlib.Path including pathlib.Path.glob.
The text was updated successfully, but these errors were encountered: