Skip to content

Commit 0c257c9

Browse files
committed
[test/util] Add central test directory
1 parent e9b2024 commit 0c257c9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/util.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,21 @@
55
import tempfile
66

77
ODML_CACHE_DIR = os.path.join(tempfile.gettempdir(), "odml.cache")
8+
9+
TEST_TEMP_DIR = os.path.join(tempfile.gettempdir(), "odml_test")
10+
if not os.path.exists(TEST_TEMP_DIR):
11+
os.mkdir(TEST_TEMP_DIR)
12+
13+
14+
def create_test_dir(script_name):
15+
"""
16+
Takes the name of a test script and creates a like-named directory
17+
in the main test directory if it does not yet exist.
18+
19+
:param script_name: String that will be used to create the test directory
20+
21+
:return: Path to the test directory.
22+
"""
23+
dir_name = "_%s" % os.path.basename(os.path.splitext(script_name)[0])
24+
25+
return tempfile.mkdtemp(suffix=dir_name, dir=TEST_TEMP_DIR)

0 commit comments

Comments
 (0)