/
test_refactoring.py
34 lines (25 loc) · 1.04 KB
/
test_refactoring.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
from fitness.RefactorFitness import RefactorFitness
"""
Tests a specified refactoring on a codebase.
The edited file will be stored in temp/
"""
# Path to the input codebase (singular python file at the moment)
file_path = "codebases/sample1/test.py"
# Class name of the refactoring you want to test
refactoring_type = "MergeNestedIfStatement"
# Index of target you want to apply the refactoring to
# -1 if you just want a display of the targets (to check if there are any)
target_index = 0
###################################################
fit = RefactorFitness(codebase=file_path,
refactorer_engine='custom',
similarity_client='test_dummy')
targets = fit.available_refactorings[refactoring_type]
print('targets: {}\n'.format(fit.available_refactorings))
print('targets: {}\n'.format(targets))
if target_index >= 0:
sequences = list()
sequences.append([(refactoring_type, targets[target_index])])
print(f'sequences: {sequences}')
fitness_value = fit(sequences)[0]
print(fitness_value)