Skip to content

Commit fb66ff5

Browse files
committed
add unit tests
1 parent 4ae0f93 commit fb66ff5

File tree

7 files changed

+59
-59
lines changed

7 files changed

+59
-59
lines changed

codeflash/verification/pytest_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def pytest_runtest_setup(self, item: pytest.Item) -> None:
468468
os.environ["CODEFLASH_TEST_FUNCTION"] = test_function_name
469469

470470
@pytest.hookimpl(trylast=True)
471-
def pytest_runtest_teardown(self, _: pytest.Item) -> None:
471+
def pytest_runtest_teardown(self, item: pytest.Item) -> None:
472472
"""Clean up test context environment variables after each test."""
473473
for var in ["CODEFLASH_TEST_MODULE", "CODEFLASH_TEST_CLASS", "CODEFLASH_TEST_FUNCTION"]:
474474
os.environ.pop(var, None)

tests/test_async_run_and_parse_tests.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async def test_async_sort():
9292
]
9393
)
9494

95-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
95+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
9696
testing_type=TestingMode.BEHAVIOR,
9797
test_env=test_env,
9898
test_files=func_optimizer.test_files,
@@ -107,7 +107,7 @@ async def test_async_sort():
107107

108108
results_list = test_results.test_results
109109
assert results_list[0].id.function_getting_tested == "async_sorter"
110-
assert results_list[0].id.test_class_name == "PytestPluginManager"
110+
assert results_list[0].id.test_class_name is None
111111
assert results_list[0].id.test_function_name == "test_async_sort"
112112
assert results_list[0].did_pass
113113
assert results_list[0].runtime is None or results_list[0].runtime >= 0
@@ -211,7 +211,7 @@ async def test_async_class_sort():
211211
]
212212
)
213213

214-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
214+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
215215
testing_type=TestingMode.BEHAVIOR,
216216
test_env=test_env,
217217
test_files=func_optimizer.test_files,
@@ -233,7 +233,7 @@ async def test_async_class_sort():
233233

234234

235235
assert sorter_result.id.function_getting_tested == "sorter"
236-
assert sorter_result.id.test_class_name == "PytestPluginManager"
236+
assert sorter_result.id.test_class_name is None
237237
assert sorter_result.id.test_function_name == "test_async_class_sort"
238238
assert sorter_result.did_pass
239239
assert sorter_result.runtime is None or sorter_result.runtime >= 0
@@ -320,7 +320,7 @@ async def test_async_perf():
320320
]
321321
)
322322

323-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
323+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
324324
testing_type=TestingMode.PERFORMANCE,
325325
test_env=test_env,
326326
test_files=func_optimizer.test_files,
@@ -473,7 +473,7 @@ async def async_error_function(lst):
473473
]
474474
)
475475

476-
test_results, _ = func_optimizer.run_and_parse_tests(
476+
test_results, _, _ = func_optimizer.run_and_parse_tests(
477477
testing_type=TestingMode.BEHAVIOR,
478478
test_env=test_env,
479479
test_files=func_optimizer.test_files,
@@ -567,7 +567,7 @@ async def test_async_multi():
567567
]
568568
)
569569

570-
test_results, _ = func_optimizer.run_and_parse_tests(
570+
test_results, _, _ = func_optimizer.run_and_parse_tests(
571571
testing_type=TestingMode.BEHAVIOR,
572572
test_env=test_env,
573573
test_files=func_optimizer.test_files,
@@ -678,7 +678,7 @@ async def test_async_edge_cases():
678678
]
679679
)
680680

681-
test_results, _ = func_optimizer.run_and_parse_tests(
681+
test_results, _, _ = func_optimizer.run_and_parse_tests(
682682
testing_type=TestingMode.BEHAVIOR,
683683
test_env=test_env,
684684
test_files=func_optimizer.test_files,
@@ -810,7 +810,7 @@ def test_sync_sort():
810810
]
811811
)
812812

813-
test_results, _ = func_optimizer.run_and_parse_tests(
813+
test_results, _, _ = func_optimizer.run_and_parse_tests(
814814
testing_type=TestingMode.BEHAVIOR,
815815
test_env=test_env,
816816
test_files=func_optimizer.test_files,
@@ -976,7 +976,7 @@ async def test_mixed_sorting():
976976
]
977977
)
978978

979-
test_results, _ = func_optimizer.run_and_parse_tests(
979+
test_results, _, _ = func_optimizer.run_and_parse_tests(
980980
testing_type=TestingMode.BEHAVIOR,
981981
test_env=test_env,
982982
test_files=func_optimizer.test_files,

tests/test_codeflash_capture.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def __init__(self, x=2):
459459
)
460460
]
461461
)
462-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
462+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
463463
testing_type=TestingMode.BEHAVIOR,
464464
test_env=test_env,
465465
test_files=func_optimizer.test_files,
@@ -492,7 +492,7 @@ def __init__(self, x=2):
492492
assert test_results[2].id.function_getting_tested == "some_function"
493493
assert test_results[2].id.iteration_id == "16_0"
494494

495-
test_results2, _ = func_optimizer.run_and_parse_tests(
495+
test_results2, _, _ = func_optimizer.run_and_parse_tests(
496496
testing_type=TestingMode.BEHAVIOR,
497497
test_env=test_env,
498498
test_files=func_optimizer.test_files,
@@ -580,7 +580,7 @@ def __init__(self, *args, **kwargs):
580580
)
581581
]
582582
)
583-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
583+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
584584
testing_type=TestingMode.BEHAVIOR,
585585
test_env=test_env,
586586
test_files=func_optimizer.test_files,
@@ -614,7 +614,7 @@ def __init__(self, *args, **kwargs):
614614
assert test_results[2].id.function_getting_tested == "some_function"
615615
assert test_results[2].id.iteration_id == "16_0"
616616

617-
results2, _ = func_optimizer.run_and_parse_tests(
617+
results2, _, _ = func_optimizer.run_and_parse_tests(
618618
testing_type=TestingMode.BEHAVIOR,
619619
test_env=test_env,
620620
test_files=func_optimizer.test_files,
@@ -705,7 +705,7 @@ def __init__(self, x=2):
705705
)
706706
]
707707
)
708-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
708+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
709709
testing_type=TestingMode.BEHAVIOR,
710710
test_env=test_env,
711711
test_files=func_optimizer.test_files,
@@ -741,7 +741,7 @@ def __init__(self, x=2):
741741
assert test_results[2].id.function_getting_tested == "some_function"
742742
assert test_results[2].id.iteration_id == "12_2" # Third call
743743

744-
test_results2, _ = func_optimizer.run_and_parse_tests(
744+
test_results2, _, _ = func_optimizer.run_and_parse_tests(
745745
testing_type=TestingMode.BEHAVIOR,
746746
test_env=test_env,
747747
test_files=func_optimizer.test_files,
@@ -867,7 +867,7 @@ def another_helper(self):
867867
]
868868
)
869869

870-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
870+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
871871
testing_type=TestingMode.BEHAVIOR,
872872
test_env=test_env,
873873
test_files=func_optimizer.test_files,
@@ -888,7 +888,7 @@ def another_helper(self):
888888
assert test_results[3].id.function_getting_tested == "AnotherHelperClass.__init__"
889889
assert test_results[3].verification_type == VerificationType.INIT_STATE_HELPER
890890

891-
results2, _ = func_optimizer.run_and_parse_tests(
891+
results2, _, _ = func_optimizer.run_and_parse_tests(
892892
testing_type=TestingMode.BEHAVIOR,
893893
test_env=test_env,
894894
test_files=func_optimizer.test_files,
@@ -1026,7 +1026,7 @@ def another_helper(self):
10261026
}
10271027
instrument_codeflash_capture(fto, file_path_to_helper_classes, tests_root)
10281028

1029-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
1029+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
10301030
testing_type=TestingMode.BEHAVIOR,
10311031
test_env=test_env,
10321032
test_files=func_optimizer.test_files,
@@ -1078,7 +1078,7 @@ def target_function(self):
10781078
Path(helper_path_2): {"HelperClass2", "AnotherHelperClass"},
10791079
}
10801080
instrument_codeflash_capture(fto, file_path_to_helper_classes, tests_root)
1081-
modified_test_results, coverage_data = func_optimizer.run_and_parse_tests(
1081+
modified_test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
10821082
testing_type=TestingMode.BEHAVIOR,
10831083
test_env=test_env,
10841084
test_files=func_optimizer.test_files,
@@ -1117,7 +1117,7 @@ def target_function(self):
11171117
Path(helper_path_2): {"HelperClass2", "AnotherHelperClass"},
11181118
}
11191119
instrument_codeflash_capture(fto, file_path_to_helper_classes, tests_root)
1120-
mutated_test_results, coverage_data = func_optimizer.run_and_parse_tests(
1120+
mutated_test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
11211121
testing_type=TestingMode.BEHAVIOR,
11221122
test_env=test_env,
11231123
test_files=func_optimizer.test_files,
@@ -1155,7 +1155,7 @@ def target_function(self):
11551155
Path(helper_path_2): {"HelperClass2", "AnotherHelperClass"},
11561156
}
11571157
instrument_codeflash_capture(fto, file_path_to_helper_classes, tests_root)
1158-
no_helper1_test_results, coverage_data = func_optimizer.run_and_parse_tests(
1158+
no_helper1_test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
11591159
testing_type=TestingMode.BEHAVIOR,
11601160
test_env=test_env,
11611161
test_files=func_optimizer.test_files,

tests/test_instrument_all_and_run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_sort():
160160
)
161161
]
162162
)
163-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
163+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
164164
testing_type=TestingMode.BEHAVIOR,
165165
test_env=test_env,
166166
test_files=func_optimizer.test_files,
@@ -205,7 +205,7 @@ def test_sort():
205205
result: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
206206
"""
207207
assert test_results[1].stdout == out_str
208-
results2, _ = func_optimizer.run_and_parse_tests(
208+
results2, _, _ = func_optimizer.run_and_parse_tests(
209209
testing_type=TestingMode.BEHAVIOR,
210210
test_env=test_env,
211211
test_files=func_optimizer.test_files,
@@ -331,7 +331,7 @@ def test_sort():
331331
)
332332
]
333333
)
334-
test_results, coverage_data = func_optimizer.run_and_parse_tests(
334+
test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
335335
testing_type=TestingMode.BEHAVIOR,
336336
test_env=test_env,
337337
test_files=func_optimizer.test_files,
@@ -376,7 +376,7 @@ def test_sort():
376376
assert test_results[3].did_pass
377377
assert test_results[3].stdout == """codeflash stdout : BubbleSorter.sorter() called\n"""
378378

379-
results2, _ = func_optimizer.run_and_parse_tests(
379+
results2, _, _ = func_optimizer.run_and_parse_tests(
380380
testing_type=TestingMode.BEHAVIOR,
381381
test_env=test_env,
382382
test_files=func_optimizer.test_files,
@@ -439,7 +439,7 @@ def sorter(self, arr):
439439
)
440440
]
441441
)
442-
new_test_results, coverage_data = func_optimizer.run_and_parse_tests(
442+
new_test_results, coverage_data, _ = func_optimizer.run_and_parse_tests(
443443
testing_type=TestingMode.BEHAVIOR,
444444
test_env=test_env,
445445
test_files=func_optimizer.test_files,

0 commit comments

Comments
 (0)