[issue39029] TestMaildir.test_clean fails randomly under parallel tests

STINNER Victor report at bugs.python.org
Thu Jan 9 05:25:09 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

> yes, the test uses support.TESTFN which has the value of "{}_{}_tmp".format(TESTFN, os.getpid()) in the setUp [0] to create tempdir. Under parallel tests the pid value of TESTFN is initialised with a pid once and used always in the setup calls. So setup acts under parallel tests with same test folder. The tempdir can be dynamically generated but I guess this pattern to use support.TESTFN is common and there could be other flaky tests.

I don't understand. Let's say that test_mailbox and test_os are run in parallel, process 1 runs test_mailbox and process 2 runs test_os. TESTFN should be different in each process but globally unique.

So I don't understand the difference between:

-        self._path = support.TESTFN

and:

+        self._tempdir = tempfile.TemporaryDirectory()
+        self._path = self._tempdir.name

Is it because the test currently doesn't remove self._path directory in some cases?

You wrote "I guess the file is not really deleted in some cases." I think that this should be investigated first.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39029>
_______________________________________


More information about the Python-bugs-list mailing list