[Python-Dev] Tests failing on Windows with TESTFN (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Fri Jul 27 01:05:51 EDT 2018
- Previous message (by thread): [Python-Dev] Tests failing on Windows with TESTFN
- Next message (by thread): [Python-Dev] Tests failing on Windows with TESTFN
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
25.07.18 18:07, Tim Golden пише:
I'm just easing back into core development work by trying to get a stable testing environment for Python development on Windows.
One problem is that certain tests use support.TESTFN (a local directory constructed from the pid) for output files etc. However this can cause issues on Windows when recreating the folders / files for multiple tests, especially when running in parallel. Here's an example on my laptop deliberately running 3 tests with -j0 which I know will generate an error about one time in three: C:\work-in-progress\cpython>python -mtest -j0 testurllib2 testbz2 testimportlib Running Debug|Win32 interpreter... Run tests in parallel using 6 child processes 0:00:23 [1/3/1] testurllib2 failed test testurllib2 failed -- Traceback (most recent call last): File "C:\work-in-progress\cpython\lib\test\testurllib2.py", line 821, in testfile f = open(TESTFN, "wb") PermissionError: [Errno 13] Permission denied: '@test15564tmp' Although these errors are both intermittent and fairly easily spotted, the effect is that I rarely get a clean test run when I'm applying a patch.
Try to use test.support.unlink() instead of os.unlink(). It is purposed for solving this issue.
I started to address this years ago but things stalled. I'm happy to pick this up again and have another go, but I wanted to ask first whether there was any objection to my converting tests to using tempfile functions which should avoid the problem?
I think the only concern is that it is a pretty large change across many files, and there is a risk of introducing bugs. Also, creating a temporary file in setUp() may slowdown testing, especially if TESTFN is not needed in every test.
- Previous message (by thread): [Python-Dev] Tests failing on Windows with TESTFN
- Next message (by thread): [Python-Dev] Tests failing on Windows with TESTFN
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]