Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import os |
||
2 | |||
3 | |||
4 | def get_test_files(): |
||
5 | """ |
||
6 | Create a list of test files in the test directory |
||
7 | excluding .pyc and __pycache__ |
||
8 | |||
9 | :return: list |
||
10 | """ |
||
11 | test_files = os.listdir('./test') |
||
12 | return [ |
||
13 | create_test_file_name(test_file) |
||
14 | for test_file in test_files |
||
15 | if is_valid_test_file(test_files) |
||
16 | ] |
||
17 | |||
18 | |||
19 | def is_valid_test_file(test_file): |
||
20 | """ |
||
21 | Checks if file is a .pyc or from __pycache__ |
||
22 | :param test_file: str |
||
23 | :return: str |
||
24 | """ |
||
25 | return '.pyc' not in test_file and '__pycache__' not in test_file |
||
26 | |||
27 | |||
28 | def create_test_file_name(test_file): |
||
29 | """ |
||
30 | Append `test.` over file names to run all tests via `unittest` |
||
31 | :param test_file: str |
||
32 | :return: str |
||
33 | """ |
||
34 | 'test.{}'.format(test_file.replace('.py', '')) |
||
35 | |||
36 | |||
37 | def test_command(source): |
||
38 | """ |
||
39 | Creates a command to be run via subprocess |
||
40 | :param source: str|None |
||
41 | :return: list |
||
42 | """ |
||
43 | command = ['pytest', '--cov', source] if source is not None else ['pytest', '--cov'] |
||
44 | return command |
||
45 |