python-fsutil
python-fsutil copied to clipboard
fsutil write_file atomic=True destroys created file on exit
Python version 3.10
Package version latest
Current behavior (bug description) write_file atomic=True destroys the created file on exit. Obviously fsutil is not designed for running on Windows. Cannot handle directory names etc.
Expected behavior created file should stay
Test Results: pytest_result.txt
@williwacker actually all tests run successfully even on Windows. Can you help me to figure how to make the CI fail (when it should) when running on Windows?
Hi Fabio, I am wondering how the test can run on your windows machine where windows paths are always created wit backslashes and the tests comparing the given paths (using forward slashes) with the created ones are different. I cannot say what is different on my system from yours. My suggestion would be calling Pathlib.PurePath(path).as_posix(). With this approach paths are always with forward slashes. Regards Werner
How I was testing: copied the testcase file into my temp folder and started pytest from this folder.
@williwacker I have not a Windows machine, I run tests locally using tox and remotely on Linux / MacOS / Windows using the GitHub CI.
The tests are based on unittest and not on pytest.
For testing, please follow the instructions in the README testing section.
@fabiocaccamo, Simular result when running unittest. unittest.txt
@williwacker thank you for the feedback, this is probably just a tests problem because paths are hardcoded, I will try to fix tests as soon as possible and ask you to check again.
Anyway, I don't understand why the GitHub CI doesn't fail when running on Windows.
@williwacker I improved some tests for Windows compatibility, could you please pull from master, run tests and send me the errors report?
Hi @fabiocaccamo, Much better but not perfect yet. I guess the permission test cases can be ignored on windows, but the atomic write file tests are important. Thanks unittest.result.txt
@williwacker exactly what I expected, I also agree with skipping permission test cases on Windows. I will try to figure out the atomic write file tests issue (if you have any hint let me know). Thanks for the updated errors report.
@williwacker I would ask you to pull from master and test it again.
All tests should succeed now (permissions tests skipped on Windows), except atomic write file tests that should still fail, but I would ask you to do a couple of tests locally:
- Try setting this parameter to
False - Try uncommenting this parameter (only if you're using Python >= 3.12)
Hi @fabiocaccamo, have tested the new code with both delete=true and false and have pasted the output in here. Thanks test_result_delete_false.txt test_result_delete_true.txt