Completed
Push — master ( 6428b9...0f7b85 )
by Amresh
47:18 queued 45:49
created

fastest.compiler.compile_tests   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 18
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A build() 0 20 5
1
import os
2
from fastest.bodies import f
3
4
5
def build(function_objects, src_file_path, base_path):
6
    test_file_name = src_file_path.split('/')[-1].replace('.py', '__test.py')
7
    deps_import = src_file_path.replace(base_path + '/', '').replace('/', '.').replace('.py', '')
8
    root_module_name = deps_import.split('.')[-1]
9
    test_file_path = os.path.join(base_path, 'test', test_file_name)
10
11
    with open(test_file_path, 'w+') as fp:
12
        fp.write('import unittest\n\n')
13
        for function_object in function_objects:
14
            fp.write('from {} import {}\n'.format(deps_import, function_object['name']))
15
16
        for function_object in function_objects:
17
            fp.write(
18
                """\n
19
class Test_{}_{}(unittest.TestCase):
20
           
21
                """.format(root_module_name, function_object['name'])
22
            )
23
            for test in function_object['tests']:
24
                fp.write(f.create_naive_test_case(function_object, test))