-
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
PureWindowsPath.stem
changes behavior when fs
fixture is loaded
#1006
Comments
Thank you! This is probably due to the handling of backslashes under Linux. Even if using At the moment, you need to set the OS to Windows, if you want this to work, e.g. import pathlib
from pyfakefs.fake_filesystem import OSType
def test_pyfakefs(fs):
fs.os = OSType.WINDOWS
assert pathlib.PureWindowsPath(r"C:\example\demo.py").stem == "demo" |
I'm curious why you need this, anyway: do you want to test Windows behavior under Linux (in which case you would need to set the OS anyway), or is this some other use case? |
I'm using #!"C:\Program Files\Python39\python.exe" -v
print("Running on a specific interpreter, with arguments") To accommodate this, I'm using I'm very happy to submit a PR for this, and have already forked this repo for the purpose. If you can point me to the correct place to add/fix this, it'll give me a jump start (I'm assuming it's in |
Thank you for the explanation - that makes sense! A PR would be nice, of course, but I'm not sure if this is an easy fix. The changes probably need be done in Anyway, any help is appreciated, and if you want to have a go at a PR, go ahead! But as I wrote, I'm not sure if this will be easy, so it is of course your decision if you want to try it. |
@kurtmckee - do you want to have a go at this first, or shall I look at it myself? |
Haha, "but I've been working to get the test suite just right to prepare to work on this..."! 😆 If you already know what the change will look like, please go for it! Otherwise, I'll leave a note on this issue when I have availability to dig in again. 👍 |
Well, I don't want to deprive you of that work 😁 I don't know how the change will look like yet, though I may have a closer look at the weekend. If I find something out, I'll let you know. If you get the time to work on it, I would prefer that (especially after seeing how fast you resolved the test issue). I like it that somebody else has a look at the code, to get another perspective - I mostly work alone on this project, which I find a bit unfortunate. |
That makes total sense to me! I'll tackle this one. 😁 |
I ended up having a flight delayed for several hours, which gave me an opportunity to look into this. 👍 |
* Hard-code path separators in `Pure*Path` classes * Fixes #1006
Thank you! Do you need a patch release, or can you wait a bit? |
This will unblock some work I was doing, but I won't be able to return to that work until next week at the earliest. Please don't feel pressure to get this out the door ASAP! Thanks for your work on pyfakefs! |
Ok, I will check if I can handle another issue first, and make a patch release after that. |
FYI: The release is out. |
Awesome, thank you! |
Describe the bug
When the
fs
fixture is loaded,pathlib.PureWindowsPath.stem
returns more than the file's stem.How To Reproduce
Create a file named
test_demo.py
with this content:Then run:
You will see the following output:
Your environment
The text was updated successfully, but these errors were encountered: