Message359031
> Should not parallel tests be ran in different directories?
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.
# create tempdir at setup each time and clean it up.
diff --git Lib/test/test_mailbox.py Lib/test/test_mailbox.py
index 36a265390e..aa8ae9ae20 100644
--- Lib/test/test_mailbox.py
+++ Lib/test/test_mailbox.py
@@ -51,13 +51,15 @@ class TestMailbox(TestBase):
_template = 'From: foo\n\n%s\n'
def setUp(self):
- self._path = support.TESTFN
+ self._tempdir = tempfile.TemporaryDirectory()
+ self._path = self._tempdir.name
self._delete_recursively(self._path)
self._box = self._factory(self._path)
def tearDown(self):
self._box.close()
self._delete_recursively(self._path)
+ self._tempdir.cleanup()
def test_add(self):
# Add copies of a sample message
[0] https://github.com/python/cpython/blob/88dce26da6bc4838092128d9a6f1c98bf48b7c90/Lib/test/test_mailbox.py#L54 |
|
Date |
User |
Action |
Args |
2019-12-30 10:37:46 | xtreak | set | recipients:
+ xtreak, barry, vstinner, r.david.murray, serhiy.storchaka, maxking |
2019-12-30 10:37:46 | xtreak | set | messageid: <1577702266.02.0.697349215158.issue39029@roundup.psfhosted.org> |
2019-12-30 10:37:46 | xtreak | link | issue39029 messages |
2019-12-30 10:37:45 | xtreak | create | |
|