[Python-Dev] Tests failing on Windows with TESTFN

Tim Golden mail at timgolden.me.uk
Wed Jul 25 11:07:09 EDT 2018

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 test_urllib2 test_bz2 

Running Debug|Win32 interpreter...
Run tests in parallel using 6 child processes
0:00:23 [1/3/1] test_urllib2 failed
test test_urllib2 failed -- Traceback (most recent call last):
   File "C:\work-in-progress\cpython\lib\test\test_urllib2.py", line 
821, in test_file
     f = open(TESTFN, "wb")
PermissionError: [Errno 13] Permission denied: '@test_15564_tmp'

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.

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?


More information about the Python-Dev mailing list