Skip to content

python 3.9.18 + pyfakefs + pathlib + class variable: test failed #943

Discussion options

You must be logged in to vote

Ok, I had another look here, and I really don't see a possibility to fix in Python < 3.11 without using a mock as shown in your comment, or reloading the code containing the class variable path. I have played around a bit trying it, but found no way that is not quite complicated and slow.

The problem is that in these Python versions, an accessor was used to access the file system, a reference to which was saved in every Path instance. This accessor was overwritten in pyfakefs, but if the path has been created before the patching, it remained in the path as before.
Accessing the path like it was done in the example (PATH.is_file()) directly accesses this non-patched accessor, and patching …

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by khiker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #935 on February 06, 2024 19:19.