Repository navigation
Expand file tree
/
Copy pathutils.py
More file actions
65 lines (48 loc) · 1.51 KB
/
Copy pathutils.py
File metadata and controls
65 lines (48 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
# (C) 2015 Minoru Akagi
# SPDX-License-Identifier: GPL-2.0-or-later
# begin: 2015-09-14
import os
import shutil
from Qgis2threejs.utils.basic import pluginDir
from Qgis2threejs.utils.logging import logger
MY_TEST_TEMPDIR = "E:/dev/qgis2threejs_test"
def testDir(*subdirs):
return pluginDir("tests", *subdirs)
def dataPath(*subdirs):
dataDir = testDir("data")
if subdirs:
return os.path.join(dataDir, *subdirs)
return dataDir
def expectedDataPath(*subdirs):
if os.path.exists(MY_TEST_TEMPDIR):
dataDir = MY_TEST_TEMPDIR + "/expected"
else:
dataDir = testDir("expected")
logger.warning("Expected data not exist.") # TODO
if subdirs:
return os.path.join(dataDir, *subdirs)
return dataDir
def outputPath(*subdirs):
if os.path.exists(MY_TEST_TEMPDIR):
dataDir = MY_TEST_TEMPDIR + "/output"
else:
dataDir = testDir("output")
if subdirs:
return os.path.join(dataDir, *subdirs)
return dataDir
def initOutputDir(*subdirs):
"""initialize output directory"""
out_dir = outputPath(*subdirs)
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
os.makedirs(out_dir)
def assertMessagesAppearInOrder(logs, expected):
"""check if expected messages appear in logs in order"""
it = iter(logs)
for msg in expected:
for log in it:
if msg in log:
break
else:
raise Exception(f'"{msg}" not found in logs in order.')