testgenie-py 0.1.6__py3-none-any.whl → 0.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- testgen/.coverage +0 -0
- testgen/analyzer/random_feedback_analyzer.py +3 -3
- testgen/code_to_test/__init__.py +0 -0
- testgen/code_to_test/boolean.py +146 -0
- testgen/code_to_test/calculator.py +29 -0
- testgen/code_to_test/code_to_fuzz.py +234 -0
- testgen/code_to_test/code_to_fuzz_lite.py +397 -0
- testgen/code_to_test/decisions.py +57 -0
- testgen/code_to_test/math_utils.py +47 -0
- testgen/code_to_test/no_types.py +35 -0
- testgen/code_to_test/sample_code_bin.py +141 -0
- testgen/controller/cli_controller.py +119 -99
- testgen/controller/docker_controller.py +34 -19
- testgen/docker/Dockerfile +2 -2
- testgen/docker/poetry.lock +246 -8
- testgen/docker/pyproject.toml +9 -2
- testgen/q_table/global_q_table.json +1 -1
- testgen/reinforcement/environment.py +42 -10
- testgen/reinforcement/statement_coverage_state.py +1 -1
- testgen/service/analysis_service.py +8 -2
- testgen/service/cfg_service.py +1 -1
- testgen/service/generator_service.py +11 -3
- testgen/service/logging_service.py +100 -0
- testgen/service/service.py +81 -41
- testgen/testgen.db +0 -0
- testgen/util/coverage_utils.py +41 -14
- testgen/util/coverage_visualizer.py +2 -2
- testgen/util/file_utils.py +46 -0
- testgen/util/randomizer.py +27 -12
- testgen/util/z3_utils/z3_test_case.py +26 -11
- {testgenie_py-0.1.6.dist-info → testgenie_py-0.1.7.dist-info}/METADATA +1 -1
- {testgenie_py-0.1.6.dist-info → testgenie_py-0.1.7.dist-info}/RECORD +34 -22
- {testgenie_py-0.1.6.dist-info → testgenie_py-0.1.7.dist-info}/WHEEL +0 -0
- {testgenie_py-0.1.6.dist-info → testgenie_py-0.1.7.dist-info}/entry_points.txt +0 -0
@@ -9,7 +9,7 @@ from testgen.util.z3_utils import ast_to_z3
|
|
9
9
|
from testgen.util.z3_utils.constraint_extractor import extract_branch_conditions
|
10
10
|
|
11
11
|
|
12
|
-
def solve_branch_condition(file_name: str, func_node: ast.FunctionDef, uncovered_lines: List[int]) -> List[TestCase]:
|
12
|
+
def solve_branch_condition(file_name: str, class_name: str | None, func_node: ast.FunctionDef, uncovered_lines: List[int]) -> List[TestCase]:
|
13
13
|
branch_conditions, param_types = extract_branch_conditions(func_node)
|
14
14
|
uncovered_conditions = [bc for bc in branch_conditions if bc.line_number in uncovered_lines]
|
15
15
|
test_cases = []
|
@@ -25,6 +25,10 @@ def solve_branch_condition(file_name: str, func_node: ast.FunctionDef, uncovered
|
|
25
25
|
# Create default values for all parameters
|
26
26
|
param_values = {}
|
27
27
|
for param_name in param_types:
|
28
|
+
# Skip 'self' parameter for class methods
|
29
|
+
if param_name == 'self':
|
30
|
+
continue
|
31
|
+
|
28
32
|
# Set default values based on type
|
29
33
|
if param_types[param_name] == "int":
|
30
34
|
param_values[param_name] = 0
|
@@ -39,32 +43,38 @@ def solve_branch_condition(file_name: str, func_node: ast.FunctionDef, uncovered
|
|
39
43
|
|
40
44
|
# Update with model values where available
|
41
45
|
for var_name, z3_var in z3_vars.items():
|
42
|
-
if var_name in param_types
|
46
|
+
if var_name in param_types:
|
43
47
|
try:
|
48
|
+
|
49
|
+
model_value = model.evaluate(z3_var)
|
50
|
+
|
44
51
|
if param_types[var_name] == "int":
|
45
|
-
param_values[var_name] =
|
52
|
+
param_values[var_name] = model_value.as_long()
|
46
53
|
elif param_types[var_name] == "float":
|
47
|
-
param_values[var_name] = float(
|
54
|
+
param_values[var_name] = float(model_value.as_decimal(10))
|
48
55
|
elif param_types[var_name] == "bool":
|
49
|
-
param_values[var_name] = z3.is_true(
|
56
|
+
param_values[var_name] = z3.is_true(model_value)
|
50
57
|
elif param_types[var_name] == "str":
|
51
|
-
|
58
|
+
str_val = str(model_value)
|
59
|
+
if str_val.startswith('"') and str_val.endswith('"'):
|
60
|
+
str_val = str_val[1:-1]
|
61
|
+
param_values[var_name] = str_val
|
52
62
|
else:
|
53
63
|
param_values[var_name] = model[z3_var].as_long()
|
54
64
|
except Exception as e:
|
55
|
-
print(f"
|
65
|
+
print(f"Couldn't get {var_name} from model: {e}")
|
66
|
+
# Keep the default value we already set
|
56
67
|
|
57
68
|
# Ensure all parameters are included in correct order
|
58
69
|
ordered_params = []
|
59
70
|
for arg in func_node.args.args:
|
60
71
|
arg_name = arg.arg
|
61
|
-
if arg_name == 'self': # Skip self parameter
|
72
|
+
if arg_name == 'self': # Skip self parameter
|
62
73
|
continue
|
63
74
|
if arg_name in param_values:
|
64
75
|
ordered_params.append(param_values[arg_name])
|
65
76
|
else:
|
66
|
-
|
67
|
-
# Provide default values based on annotation if available
|
77
|
+
# Default value handling if parameter not in solution
|
68
78
|
if hasattr(arg, 'annotation') and arg.annotation:
|
69
79
|
if isinstance(arg.annotation, ast.Name):
|
70
80
|
if arg.annotation.id == 'int':
|
@@ -85,7 +95,12 @@ def solve_branch_condition(file_name: str, func_node: ast.FunctionDef, uncovered
|
|
85
95
|
func_name = func_node.name
|
86
96
|
try:
|
87
97
|
module = testgen.util.file_utils.load_module(file_name)
|
88
|
-
|
98
|
+
if class_name is not None:
|
99
|
+
class_obj = getattr(module, class_name)
|
100
|
+
instance = class_obj()
|
101
|
+
func = getattr(instance, func_name)
|
102
|
+
else:
|
103
|
+
func = getattr(module, func_name)
|
89
104
|
result = func(*ordered_params)
|
90
105
|
test_cases.append(TestCase(func_name, tuple(ordered_params), result))
|
91
106
|
except Exception as e:
|
@@ -1,3 +1,4 @@
|
|
1
|
+
testgen/.coverage,sha256=LBC31i6ROQvL24jd3a-mAlGfailO1bmEWlrTCTbxC8s,53248
|
1
2
|
testgen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
3
|
testgen/analyzer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
4
|
testgen/analyzer/ast_analyzer.py,sha256=JmqiosxgZJm2fhNDr5VUBpKKHmf8S2HP9Jm0Xl7NnnI,6783
|
@@ -6,16 +7,25 @@ testgen/analyzer/contracts/contract.py,sha256=6rNYJOy_2GrOhGtaXTDIOX6pTEOqo856Fx
|
|
6
7
|
testgen/analyzer/contracts/no_exception_contract.py,sha256=rTWTuu5XKmvzBPD6yNAqiNehk9lbWn_Z8zFj-_djZ_w,512
|
7
8
|
testgen/analyzer/contracts/nonnull_contract.py,sha256=uurnrVptImYTVpSnu8ckdlU6c94AbiOWFoH1YnAQU0w,508
|
8
9
|
testgen/analyzer/fuzz_analyzer.py,sha256=ktkDdh3mgHjcC4ZitGo9fa9RjnGqkdehaYJeSKssWss,4299
|
9
|
-
testgen/analyzer/random_feedback_analyzer.py,sha256=
|
10
|
+
testgen/analyzer/random_feedback_analyzer.py,sha256=tQkYwrYCH1xeSU5j1aoh0vUMyZwFC-1dFWf5eIlhcH8,13219
|
10
11
|
testgen/analyzer/reinforcement_analyzer.py,sha256=U6W7g-xDFS_P0aqxjPRnaXjGp2gOC9TMdfWaetFV7eE,3568
|
11
12
|
testgen/analyzer/test_case_analyzer.py,sha256=foHRbz9K6WAn711sXbp-smJHDjI8GTG8F2TpovLZVEo,1530
|
12
13
|
testgen/analyzer/test_case_analyzer_context.py,sha256=7umDPHBjoTaCRvZOdNynpnWsr14Gy0E2hpMBPK8mz3Q,2128
|
14
|
+
testgen/code_to_test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
+
testgen/code_to_test/boolean.py,sha256=RM2byJDKFTx1FFrxnPG_uZWb24OcOH20Uh-D1Z-yPcE,3373
|
16
|
+
testgen/code_to_test/calculator.py,sha256=j7lw21BYg_vxaQVCrjOlhQOpObjSe5gu9xzthmdGphk,830
|
17
|
+
testgen/code_to_test/code_to_fuzz.py,sha256=cwgRpUdXjTlrUHSHMtA2TAj8Y-ddAn6CaUdXPM4MRmo,4826
|
18
|
+
testgen/code_to_test/code_to_fuzz_lite.py,sha256=EjS4GB5klnJrvZIDDpS9iIt0iZETVJI0ez9DmihMiYc,10429
|
19
|
+
testgen/code_to_test/decisions.py,sha256=ZiW-EF1yTOWeQVZ7Xh0oIPHK2NSNPUzVxCY0E2GbYvQ,1376
|
20
|
+
testgen/code_to_test/math_utils.py,sha256=FqPQz5-e1oklzGyTVYNO8JMKDg5ob8z05VOlpKfKvvw,853
|
21
|
+
testgen/code_to_test/no_types.py,sha256=kD8CGjVAxVeCjQC45abO773sRNIjiZ4jvhwPRV8-kt0,675
|
22
|
+
testgen/code_to_test/sample_code_bin.py,sha256=kMvV_-oFeAkxUmDx41Pw0iTTmMG1pvX31TezXPWMOkE,4225
|
13
23
|
testgen/controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
testgen/controller/cli_controller.py,sha256=
|
15
|
-
testgen/controller/docker_controller.py,sha256=
|
16
|
-
testgen/docker/Dockerfile,sha256=
|
17
|
-
testgen/docker/poetry.lock,sha256=
|
18
|
-
testgen/docker/pyproject.toml,sha256=
|
24
|
+
testgen/controller/cli_controller.py,sha256=jSwT6Cy3JQhxFPRXaODdZ1md5uXO83Q0IrYh86sIdiE,8832
|
25
|
+
testgen/controller/docker_controller.py,sha256=Jz1Nc7LW-njvCLDk3svPCVz5UDeQ7gAEFLHXrU1Yrws,7237
|
26
|
+
testgen/docker/Dockerfile,sha256=OLaWW4i6uUvVQinzYOmazGDAILyM8czcfl-ENkHLKQw,534
|
27
|
+
testgen/docker/poetry.lock,sha256=3ZPF2N4KtpMRc9qfamUXumMw7qGmQHaZDaxJ9_bMo7U,51684
|
28
|
+
testgen/docker/pyproject.toml,sha256=JWhMupWM7aQFO7-teR9sfFahKB3aM4NPO8on5P3TRxw,563
|
19
29
|
testgen/generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
30
|
testgen/generator/code_generator.py,sha256=V5Donxz3r3ZW56xyyldJwOuDBaX6e8NOyPc8UzllQs8,2467
|
21
31
|
testgen/generator/doctest_generator.py,sha256=Dkaf2l72ENk1mqNP3WkOnIY-iqrTHh-443AWtxzRWGY,8806
|
@@ -33,36 +43,38 @@ testgen/models/generator_context.py,sha256=V-T9i-3Ar-gdBzQqidyqBb05PTmOu2LtdQdAI
|
|
33
43
|
testgen/models/test_case.py,sha256=jwodn-6fKHCh4SO2qycbrFyggCb9UlwTZ8k3RdTObDQ,216
|
34
44
|
testgen/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
45
|
testgen/presentation/cli_view.py,sha256=2fZrsvZ-Wi4j37UvogsK9_yQV5o3A20jowIr6iFRu-s,296
|
36
|
-
testgen/q_table/global_q_table.json,sha256=
|
46
|
+
testgen/q_table/global_q_table.json,sha256=xSMRf5ddtLJAogE_RXleAbkmujgAYU3uiblBJmKqc5w,12059
|
37
47
|
testgen/reinforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
38
48
|
testgen/reinforcement/abstract_state.py,sha256=M9Kp8fyJzsTzpyL3ca4HjjYpGXy9DRMw-IG7OgFVisY,154
|
39
49
|
testgen/reinforcement/agent.py,sha256=wvgbi-OVoVJMwhasGgsP2y1TKLiC5qjjTwZBNqKNRns,6098
|
40
|
-
testgen/reinforcement/environment.py,sha256=
|
41
|
-
testgen/reinforcement/statement_coverage_state.py,sha256=
|
50
|
+
testgen/reinforcement/environment.py,sha256=bNsk9ejPo2ICY-FM6lwGD2W6YEuoE_N70DKazvjfrqU,10825
|
51
|
+
testgen/reinforcement/statement_coverage_state.py,sha256=mTZ0uiFnyiIoHcQXlJv9FDSH4y1r3rxltYEdZcMaSSg,1552
|
42
52
|
testgen/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
|
-
testgen/service/analysis_service.py,sha256=
|
44
|
-
testgen/service/cfg_service.py,sha256=
|
45
|
-
testgen/service/generator_service.py,sha256=
|
46
|
-
testgen/service/
|
53
|
+
testgen/service/analysis_service.py,sha256=LPvsb6XwFQIOn05niamDiJx_HqCyTX2UznREvKjfvWo,10973
|
54
|
+
testgen/service/cfg_service.py,sha256=ejgwbFlwla9Mfy4OJ-hsLAxo0TV3jO06hkldeEU-akQ,2236
|
55
|
+
testgen/service/generator_service.py,sha256=MOkojB4ipp-fRF0buW-rIgFJLlBaRQKzoRxyJksylao,7382
|
56
|
+
testgen/service/logging_service.py,sha256=vEQsluxwO-dAxWY4Xkwt8v5XeaXEv3GZh3ZYAsFCOEs,3116
|
57
|
+
testgen/service/service.py,sha256=HDHm5NS_qC5EvFCcdOJAR6B3lQb8fPEmwRfZz1dV4j0,17001
|
47
58
|
testgen/sqlite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
59
|
testgen/sqlite/db.py,sha256=RUt88ndT4CQRo9aZzLGXPHRK1iw0LyDEGnoWlOLzKGM,2390
|
49
60
|
testgen/sqlite/db_service.py,sha256=i87YkhMP0VNyug5p1tWUvnzHB8isFcSIRe9vJJTmFLA,8954
|
61
|
+
testgen/testgen.db,sha256=iyQiDqur-JoS70QD-VYkJFkgjb_YcK2jBAP2aZvvAhY,106496
|
50
62
|
testgen/tree/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
63
|
testgen/tree/node.py,sha256=ONJtbACShN4yNj1X-UslFRgLyBP6mrbg7qZr3c6dWyA,165
|
52
64
|
testgen/tree/tree_utils.py,sha256=gT7jucky6_GWVOlDI6jpv6RMeWCkntGOHIYLvHxD85k,2122
|
53
65
|
testgen/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
|
-
testgen/util/coverage_utils.py,sha256=
|
55
|
-
testgen/util/coverage_visualizer.py,sha256=
|
56
|
-
testgen/util/file_utils.py,sha256=
|
57
|
-
testgen/util/randomizer.py,sha256=
|
66
|
+
testgen/util/coverage_utils.py,sha256=Le5kC02gZewJEzzIE_Jfw17qOoPIZa9p3UTDWfwxUi0,7578
|
67
|
+
testgen/util/coverage_visualizer.py,sha256=Jp9d7SJaGKD38g4GWSOI4TusXtMYgMgQNPGrUnuVynk,5704
|
68
|
+
testgen/util/file_utils.py,sha256=wBiFKg2TjmKAx4QTMH93LOkR-pWU86frrir6eG1fpQE,5902
|
69
|
+
testgen/util/randomizer.py,sha256=J_M24XYxkPjD6wVCr8PmP_Iasc4CgwRJngxZOO6zofc,5039
|
58
70
|
testgen/util/utils.py,sha256=_TPXveAcI_TR9XLU8qaDx63CrZJDvpzSWl_gfYchJz0,5665
|
59
71
|
testgen/util/z3_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
60
72
|
testgen/util/z3_utils/ast_to_z3.py,sha256=V87cvlH2OlO7_owuVTqygymMmK_FyesBovi6qe-BUcg,3180
|
61
73
|
testgen/util/z3_utils/branch_condition.py,sha256=N9FNR-iJmxIC62NpDQNVZ1OP14rXXqYzdA_NODPDUm4,2453
|
62
74
|
testgen/util/z3_utils/constraint_extractor.py,sha256=RXJLpmk6dAvHZ27839VXKXNtdy9St1F-17-pSEFu4bM,1285
|
63
75
|
testgen/util/z3_utils/variable_finder.py,sha256=dUh3F9_L_BDMz1ybiGss09LLcM_egbitgj0FT5Nh9u4,245
|
64
|
-
testgen/util/z3_utils/z3_test_case.py,sha256=
|
65
|
-
testgenie_py-0.1.
|
66
|
-
testgenie_py-0.1.
|
67
|
-
testgenie_py-0.1.
|
68
|
-
testgenie_py-0.1.
|
76
|
+
testgen/util/z3_utils/z3_test_case.py,sha256=yF4oJOrXMLzOwDUqXdoeg83MOTl3pvc_lYaZcS01CuQ,4983
|
77
|
+
testgenie_py-0.1.7.dist-info/METADATA,sha256=NEqEmswegGYpbG08DuV50BxSw3yvYbXDQJdgujnH5I8,843
|
78
|
+
testgenie_py-0.1.7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
79
|
+
testgenie_py-0.1.7.dist-info/entry_points.txt,sha256=OUN4GqB4zHlHWwWGjwIPbur4E_ZqQgkeeqaCLhzRZgg,47
|
80
|
+
testgenie_py-0.1.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|