-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_folder_utils.py
50 lines (43 loc) · 1.59 KB
/
test_folder_utils.py
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
import os
import sys
from color import eprint
'''
Provides utility functions for working with test folders.
It includes functions for retrieving test folders in the current directory,
retrieving test files within a specific test folder, and prompting the user
to select a test folder.
'''
excluded_test_folders = ["docs"]
def get_test_folders():
"""
Retrieves a list of test folders in the current directory that contain one or more .toml files.
Returns:
list: List of test folder names.
"""
test_folders = []
for folder in os.listdir('.'):
if excluded_test_folders.__contains__(folder):
continue
if os.path.isdir(folder):
folder_path = os.path.join('.', folder)
test_files = [file for file in os.listdir(folder_path) if file.endswith('.toml')]
if len(test_files) > 0:
test_folders.append(folder)
if len(test_folders) == 0:
eprint("No test folders found in the current directory that contain .toml files.")
sys.exit(1)
return test_folders
def get_test_files(test_folder):
"""
Retrieves a list of test files in the specified test folder.
Args:
test_folder (str): Path of the test folder.
Returns:
list: List of test file paths.
"""
test_folder_path = os.path.join('.', test_folder)
test_files = [os.path.join(test_folder_path, file) for file in os.listdir(test_folder_path) if file.endswith('.toml')]
if len(test_files) == 0:
eprint("No test files found in the selected test folder.")
sys.exit(1)
return test_files