-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDataGenerator.py
More file actions
36 lines (31 loc) · 995 Bytes
/
TestDataGenerator.py
File metadata and controls
36 lines (31 loc) · 995 Bytes
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
#!/usr/bin/python
from ast import *
import BranchCollector
from CodeRunner import *
from CustomExceptions import *
from AVM import AVM
class TestDataGenerator(NodeVisitor):
def visit_FunctionDef(self, node):
"""
Visit all functions to generate test inputs.
"""
header_string = ('Generating test data for function \''
+ str(node.name)
+ '\'\n\nBranch, Corresponding input values ')
variable_names = []
for in_param in node.args.args:
try:
variable_names.append(in_param.id)
except AttributeError as e:
variable_names.append(in_param.arg)
header_string += str(variable_names)
print(header_string)
# get all possible branches of function
branches = BranchCollector.collect_branches(node)
# save successful inputs for every branching line as
# Tupel:(lineno, input_list)
input_tuples = []
for branch in branches:
# print('Searching covering input for branch ' + str(branch))
AVM().AVMsearch(node, branch, input_tuples)
print('\n')