fastest.file_handler.create_test_command   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 15
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A get_test_files() 0 12 1
A is_valid_test_file() 0 7 1
A create_test_file_name() 0 7 1
A test_command() 0 8 2
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