Replies: 2 comments 6 replies
-
I moved this to discussions, as this may be interesting to others. As described in the documentation,
With the second approach you would have to modify the tested code, but it is actually cleaner. It would also work correctly under Windows. |
Beta Was this translation helpful? Give feedback.
-
Update: |
Beta Was this translation helpful? Give feedback.
-
Hey good people, I'm sorry for the seemingly bad report, I'm not sure if this is a real bug, but I'm seeing some strange behavior on macOS. I'll try to be succinct. Please assist me in delivering more information, I am new and inexperienced.
I have a method under testing that at some point does something like:
In my test method, I provide the
fs
fixture, and I make/tmp
like this:and then I check that the file got written, etc. It all works wonderfully.
When this package is in the build pipeline (we use ADO), I get this error:
However, if I remove the creation of
/tmp
, my local test (withpython3 -m pytest
) fails with the same error (which is why I added it). Furthermore, apparently the package has been building just fine in the pipeline so far without explicitly creating/tmp
. (Yes, I know this implies we haven't been runningpytest
locally... I made changes to this package for the first time today in a long time after others had worked on it.)I also noticed that as soon as I pass the
fs
fixture to my test method, calls toos.path.exists()
start returningFalse
for directories that are present on macOS, such as/usr
, etc. I believe this is to be expected, since (by my logic) by providing thefs
fixture I'm asking for a fake FS to "overlay" the real one.However, I am not sure what is going on in the build pipeline. I think ADO uses Linux (either Debian or Ubuntu) to run their builds. I also have noticed that on macOS
/tmp
is actually a link (tmp@ -> private/tmp
) but I'm not sure of the implications of that.I can trigger the "File exists" error locally by duplicating the line:
Here are a few other details I have:
pytest
7.2.2 andpyfakefs
5.0.0 (but it's the same with 5.1.0)python:3.9-slim
in the Dockerfile), but I somehow don't think this is the issue hereAnyway, any help is appreciated, this is driving me nuts. I'll be more than happy to provide you with any information you need.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions