test_classes: Fix data import path reuse parallelism errors.

The make_import_output_dir helper function used a path determined
primarily by the filename of the fixture being used, and expected to
have complete control over that path for the duration of the test.

This resulted in nondeterministic errors if our two test classes that
ran Mattermost import code ran at the same time.
This commit is contained in:
Tim Abbott
2019-05-03 13:16:07 -07:00
parent 884c19c3bc
commit 0adb93db32

View File

@@ -63,6 +63,7 @@ import re
import ujson
import urllib
import shutil
import tempfile
API_KEYS = {} # type: Dict[str, str]
@@ -692,8 +693,8 @@ class ZulipTestCase(TestCase):
shutil.rmtree(path)
def make_import_output_dir(self, exported_from: str) -> str:
output_dir = "var/test-{}-import".format(exported_from)
self.rm_tree(output_dir)
output_dir = tempfile.mkdtemp(dir="var/",
prefix="test-" + exported_from + "-import-")
os.makedirs(output_dir, exist_ok=True)
return output_dir