Issues (6)

tests/__init__.py (1 issue)

1
import os
2
3
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
4
TEST_RESULTS_DIR = os.path.join(os.path.dirname(__file__), 'results')
5
6
IMG_NAME = 'floor plan.png'
7
IMG_PATH = os.path.join(TEST_DATA_DIR, IMG_NAME)
8
9
IMG_NAME_JPEG = 'elevation.jpg'
10
IMG_PATH_JPEG = os.path.join(TEST_DATA_DIR, IMG_NAME_JPEG)
11
12
WTR_NAME = 'watermark.png'
13
WTR_PATH = os.path.join(TEST_DATA_DIR, WTR_NAME)
14
15
16 View Code Duplication
def init_result_dir(sub_folder):
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
17
    """
18
    Initialize test result file destination directory.
19
20
    If the directory exists, delete the files it contains.
21
    Else, create the directory.
22
    """
23
    # Confirm 'results' folder exists
24
    if not os.path.isdir(TEST_RESULTS_DIR):
25
        os.mkdir(TEST_RESULTS_DIR)
26
27
    # Confirm the sub-folder exists and remove its contents, otherwise make the folder
28
    folder = os.path.join(TEST_RESULTS_DIR, sub_folder)
29
    if os.path.isdir(folder):
30
        for f in os.listdir(folder):
31
            os.remove(os.path.join(folder, f))
32
    else:
33
        os.mkdir(folder)
34
    return folder
35
36
37
__all__ = [
38
    'IMG_PATH', 'WTR_PATH', 'TEST_DATA_DIR', 'TEST_RESULTS_DIR', 'IMG_NAME_JPEG', 'IMG_PATH_JPEG', 'init_result_dir'
39
]
40