Closed sassanh closed 4 months ago
I also noticed Path().unlink
doesn't work (maybe it is working on the real filesystem) while os.remove
works.
Can you please show how you call that code? E.g. a reproducible example, if possible.
For illustration - the following test passes:
def test_fakefs(fs):
fs.os = OSType.LINUX
path = Path('/tmp/test')
path.parent.mkdir(exist_ok=True)
path.touch()
path.write_text('test')
assert path.exists()
assert os.path.exists('/tmp/test')
path.unlink()
assert not path.exists()
So you must be doing something different.
Thanks for investigating it! I probably did something wrong, I will check it when I get back to my desk.
In the future I will add reproduction snippets with my reports.
It was an issue on my side, I had pathlib
in additional_skip_names
from the past 🙈
I will make sure to create simple reproduction steps before reporting any issues in the future.
@mrbean-bremen Quick question, are Path().exists
and Path().unlink
expected to respect additional_skip_names
?
Well... I had hoped you won't ask :)
The truth is that I did want to implement a more generic solution for the handling of additional_skip_names
in pathlib
, but couldn't get it to work. The current implementation is incomplete (yes, actually all methods should respect additional_skip_names
) and ugly (using the callstack). I had hoped that it will sufficient until I get back to it, but obviously I was wrong.
Feel free to write a new issue. Maybe you even have an idea on how to implement this in a better way...
Describe the bug I call
Path().exists
immediately aftershutil.copyfile
and it returnsFalse
whileos.path.exists
returnsTrue
. I guessPath().exists
is using the real filesystem.How To Reproduce
Your environment