Skip to content

Commit d5b3b87

Browse files
committed
cleanup tests
1 parent b8d7fe6 commit d5b3b87

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

tests/test_async_run_and_parse_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,6 @@ def test_sync_sort():
799799
[CodePosition(6, 13), CodePosition(10, 13)], # Lines where sync_sorter is called
800800
func,
801801
project_root_path,
802-
"pytest",
803802
mode=TestingMode.BEHAVIOR,
804803
)
805804
os.chdir(original_cwd)

tests/test_instrument_all_and_run.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def test_sort():
120120
[CodePosition(6, 13), CodePosition(10, 13)],
121121
func,
122122
project_root_path,
123-
"pytest",
124123
mode=TestingMode.BEHAVIOR,
125124
)
126125
os.chdir(original_cwd)
@@ -291,7 +290,7 @@ def test_sort():
291290
tmp_test_path.write_text(code, encoding="utf-8")
292291

293292
success, new_test = inject_profiling_into_existing_test(
294-
tmp_test_path, [CodePosition(7, 13), CodePosition(12, 13)], fto, tmp_test_path.parent, "pytest"
293+
tmp_test_path, [CodePosition(7, 13), CodePosition(12, 13)], fto, tmp_test_path.parent
295294
)
296295
assert success
297296
assert new_test.replace('"', "'") == expected.format(
@@ -556,7 +555,7 @@ def test_sort():
556555
tmp_test_path.write_text(code, encoding="utf-8")
557556

558557
success, new_test = inject_profiling_into_existing_test(
559-
tmp_test_path, [CodePosition(6, 13), CodePosition(10, 13)], fto, tmp_test_path.parent, "pytest"
558+
tmp_test_path, [CodePosition(6, 13), CodePosition(10, 13)], fto, tmp_test_path.parent
560559
)
561560
assert success
562561
assert new_test.replace('"', "'") == expected.format(
@@ -720,7 +719,7 @@ def test_sort():
720719
tmp_test_path.write_text(code, encoding="utf-8")
721720

722721
success, new_test = inject_profiling_into_existing_test(
723-
tmp_test_path, [CodePosition(6, 13), CodePosition(10, 13)], fto, tmp_test_path.parent, "pytest"
722+
tmp_test_path, [CodePosition(6, 13), CodePosition(10, 13)], fto, tmp_test_path.parent
724723
)
725724
assert success
726725
assert new_test.replace('"', "'") == expected.format(

tests/test_instrument_async_tests.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ async def test_async_function():
263263
assert "codeflash_behavior_async" in instrumented_source
264264

265265
success, instrumented_test_code = inject_profiling_into_existing_test(
266-
test_file, [CodePosition(8, 18), CodePosition(11, 19)], func, temp_dir, "pytest", mode=TestingMode.BEHAVIOR
266+
test_file, [CodePosition(8, 18), CodePosition(11, 19)], func, temp_dir, mode=TestingMode.BEHAVIOR
267267
)
268268

269269
# For async functions, once source is decorated, test injection should fail
@@ -322,7 +322,7 @@ async def test_async_function():
322322

323323
# Now test the full pipeline with source module path
324324
success, instrumented_test_code = inject_profiling_into_existing_test(
325-
test_file, [CodePosition(8, 18)], func, temp_dir, "pytest", mode=TestingMode.PERFORMANCE
325+
test_file, [CodePosition(8, 18)], func, temp_dir, mode=TestingMode.PERFORMANCE
326326
)
327327

328328
# For async functions, once source is decorated, test injection should fail
@@ -392,7 +392,6 @@ async def test_mixed_functions():
392392
[CodePosition(8, 18), CodePosition(11, 19)],
393393
async_func,
394394
temp_dir,
395-
"pytest",
396395
mode=TestingMode.BEHAVIOR,
397396
)
398397

@@ -584,7 +583,7 @@ async def test_multiple_calls():
584583
assert len(call_positions) == 4
585584

586585
success, instrumented_test_code = inject_profiling_into_existing_test(
587-
test_file, call_positions, func, temp_dir, "pytest", mode=TestingMode.BEHAVIOR
586+
test_file, call_positions, func, temp_dir, mode=TestingMode.BEHAVIOR
588587
)
589588

590589
assert success

tests/test_instrument_tests.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def test_sort(self):
194194
[CodePosition(9, 17), CodePosition(13, 17), CodePosition(17, 17)],
195195
func,
196196
Path(f.name).parent,
197-
"unittest",
198197
)
199198
os.chdir(original_cwd)
200199
assert success
@@ -293,7 +292,7 @@ def test_prepare_image_for_yolo():
293292
run_cwd = Path(__file__).parent.parent.resolve()
294293
os.chdir(run_cwd)
295294
success, new_test = inject_profiling_into_existing_test(
296-
Path(f.name), [CodePosition(10, 14)], func, Path(f.name).parent, "pytest"
295+
Path(f.name), [CodePosition(10, 14)], func, Path(f.name).parent
297296
)
298297
os.chdir(original_cwd)
299298
assert success
@@ -402,7 +401,6 @@ def test_sort():
402401
[CodePosition(8, 14), CodePosition(12, 14)],
403402
func,
404403
project_root_path,
405-
"pytest",
406404
mode=TestingMode.BEHAVIOR,
407405
)
408406
os.chdir(original_cwd)
@@ -418,7 +416,6 @@ def test_sort():
418416
[CodePosition(8, 14), CodePosition(12, 14)],
419417
func,
420418
project_root_path,
421-
"pytest",
422419
mode=TestingMode.PERFORMANCE,
423420
)
424421
assert success
@@ -656,11 +653,11 @@ def test_sort_parametrized(input, expected_output):
656653
func = FunctionToOptimize(function_name="sorter", parents=[], file_path=code_path)
657654
os.chdir(run_cwd)
658655
success, new_test = inject_profiling_into_existing_test(
659-
test_path, [CodePosition(14, 13)], func, project_root_path, "pytest", mode=TestingMode.BEHAVIOR
656+
test_path, [CodePosition(14, 13)], func, project_root_path, mode=TestingMode.BEHAVIOR
660657
)
661658
assert success
662659
success, new_test_perf = inject_profiling_into_existing_test(
663-
test_path, [CodePosition(14, 13)], func, project_root_path, "pytest", mode=TestingMode.PERFORMANCE
660+
test_path, [CodePosition(14, 13)], func, project_root_path, mode=TestingMode.PERFORMANCE
664661
)
665662

666663
os.chdir(original_cwd)
@@ -933,11 +930,11 @@ def test_sort_parametrized_loop(input, expected_output):
933930
func = FunctionToOptimize(function_name="sorter", parents=[], file_path=code_path)
934931
os.chdir(run_cwd)
935932
success, new_test = inject_profiling_into_existing_test(
936-
test_path, [CodePosition(15, 17)], func, project_root_path, "pytest", mode=TestingMode.BEHAVIOR
933+
test_path, [CodePosition(15, 17)], func, project_root_path, mode=TestingMode.BEHAVIOR
937934
)
938935
assert success
939936
success, new_test_perf = inject_profiling_into_existing_test(
940-
test_path, [CodePosition(15, 17)], func, project_root_path, "pytest", mode=TestingMode.PERFORMANCE
937+
test_path, [CodePosition(15, 17)], func, project_root_path, mode=TestingMode.PERFORMANCE
941938
)
942939

943940
os.chdir(original_cwd)
@@ -1293,11 +1290,11 @@ def test_sort():
12931290
func = FunctionToOptimize(function_name="sorter", parents=[], file_path=code_path)
12941291
os.chdir(str(run_cwd))
12951292
success, new_test_behavior = inject_profiling_into_existing_test(
1296-
test_path, [CodePosition(11, 17)], func, project_root_path, "pytest", mode=TestingMode.BEHAVIOR
1293+
test_path, [CodePosition(11, 17)], func, project_root_path, mode=TestingMode.BEHAVIOR
12971294
)
12981295
assert success
12991296
success, new_test_perf = inject_profiling_into_existing_test(
1300-
test_path, [CodePosition(11, 17)], func, project_root_path, "pytest", mode=TestingMode.PERFORMANCE
1297+
test_path, [CodePosition(11, 17)], func, project_root_path, mode=TestingMode.PERFORMANCE
13011298
)
13021299
os.chdir(original_cwd)
13031300
assert success
@@ -1672,7 +1669,6 @@ def test_sort(self):
16721669
[CodePosition(9, 17), CodePosition(13, 17), CodePosition(17, 17)],
16731670
func,
16741671
project_root_path,
1675-
"unittest",
16761672
mode=TestingMode.BEHAVIOR,
16771673
)
16781674
assert success
@@ -1681,7 +1677,6 @@ def test_sort(self):
16811677
[CodePosition(9, 17), CodePosition(13, 17), CodePosition(17, 17)],
16821678
func,
16831679
project_root_path,
1684-
"unittest",
16851680
mode=TestingMode.PERFORMANCE,
16861681
)
16871682
os.chdir(original_cwd)
@@ -1926,11 +1921,11 @@ def test_sort(self, input, expected_output):
19261921
func = FunctionToOptimize(function_name="sorter", parents=[], file_path=code_path)
19271922
os.chdir(run_cwd)
19281923
success, new_test_behavior = inject_profiling_into_existing_test(
1929-
test_path, [CodePosition(16, 17)], func, project_root_path, "unittest", mode=TestingMode.BEHAVIOR
1924+
test_path, [CodePosition(16, 17)], func, project_root_path, mode=TestingMode.BEHAVIOR
19301925
)
19311926
assert success
19321927
success, new_test_perf = inject_profiling_into_existing_test(
1933-
test_path, [CodePosition(16, 17)], func, project_root_path, "unittest", mode=TestingMode.PERFORMANCE
1928+
test_path, [CodePosition(16, 17)], func, project_root_path, mode=TestingMode.PERFORMANCE
19341929
)
19351930

19361931
os.chdir(original_cwd)
@@ -2186,11 +2181,11 @@ def test_sort(self):
21862181
func = FunctionToOptimize(function_name="sorter", parents=[], file_path=code_path)
21872182
os.chdir(run_cwd)
21882183
success, new_test_behavior = inject_profiling_into_existing_test(
2189-
test_path, [CodePosition(14, 21)], func, project_root_path, "unittest", mode=TestingMode.BEHAVIOR
2184+
test_path, [CodePosition(14, 21)], func, project_root_path, mode=TestingMode.BEHAVIOR
21902185
)
21912186
assert success
21922187
success, new_test_perf = inject_profiling_into_existing_test(
2193-
test_path, [CodePosition(14, 21)], func, project_root_path, "unittest", mode=TestingMode.PERFORMANCE
2188+
test_path, [CodePosition(14, 21)], func, project_root_path, mode=TestingMode.PERFORMANCE
21942189
)
21952190
os.chdir(original_cwd)
21962191
assert success
@@ -2437,10 +2432,10 @@ def test_sort(self, input, expected_output):
24372432
f = FunctionToOptimize(function_name="sorter", file_path=code_path, parents=[])
24382433
os.chdir(run_cwd)
24392434
success, new_test_behavior = inject_profiling_into_existing_test(
2440-
test_path, [CodePosition(17, 21)], f, project_root_path, "unittest", mode=TestingMode.BEHAVIOR
2435+
test_path, [CodePosition(17, 21)], f, project_root_path, mode=TestingMode.BEHAVIOR
24412436
)
24422437
success, new_test_perf = inject_profiling_into_existing_test(
2443-
test_path, [CodePosition(17, 21)], f, project_root_path, "unittest", mode=TestingMode.PERFORMANCE
2438+
test_path, [CodePosition(17, 21)], f, project_root_path, mode=TestingMode.PERFORMANCE
24442439
)
24452440
os.chdir(original_cwd)
24462441
assert success
@@ -2743,7 +2738,7 @@ def test_class_name_A_function_name():
27432738
)
27442739
os.chdir(str(run_cwd))
27452740
success, new_test = inject_profiling_into_existing_test(
2746-
test_path, [CodePosition(4, 23)], func, project_root_path, "pytest"
2741+
test_path, [CodePosition(4, 23)], func, project_root_path
27472742
)
27482743
os.chdir(original_cwd)
27492744
finally:
@@ -2820,7 +2815,7 @@ def test_common_tags_1():
28202815

28212816
os.chdir(str(run_cwd))
28222817
success, new_test = inject_profiling_into_existing_test(
2823-
test_path, [CodePosition(7, 11), CodePosition(11, 11)], func, project_root_path, "pytest"
2818+
test_path, [CodePosition(7, 11), CodePosition(11, 11)], func, project_root_path
28242819
)
28252820
os.chdir(original_cwd)
28262821
assert success
@@ -2886,7 +2881,7 @@ def test_sort():
28862881

28872882
os.chdir(str(run_cwd))
28882883
success, new_test = inject_profiling_into_existing_test(
2889-
test_path, [CodePosition(7, 15)], func, project_root_path, "pytest"
2884+
test_path, [CodePosition(7, 15)], func, project_root_path
28902885
)
28912886
os.chdir(original_cwd)
28922887
assert success
@@ -2969,7 +2964,7 @@ def test_sort():
29692964

29702965
os.chdir(run_cwd)
29712966
success, new_test = inject_profiling_into_existing_test(
2972-
test_path, [CodePosition(6, 26), CodePosition(10, 26)], function_to_optimize, project_root_path, "pytest"
2967+
test_path, [CodePosition(6, 26), CodePosition(10, 26)], function_to_optimize, project_root_path
29732968
)
29742969
os.chdir(original_cwd)
29752970
assert success
@@ -3070,7 +3065,7 @@ def test_code_replacement10() -> None:
30703065
run_cwd = Path(__file__).parent.parent.resolve()
30713066
os.chdir(run_cwd)
30723067
success, new_test = inject_profiling_into_existing_test(
3073-
test_file_path, [CodePosition(22, 28), CodePosition(28, 28)], func, test_file_path.parent, "pytest"
3068+
test_file_path, [CodePosition(22, 28), CodePosition(28, 28)], func, test_file_path.parent
30743069
)
30753070
os.chdir(original_cwd)
30763071
assert success
@@ -3128,7 +3123,7 @@ def test_sleepfunc_sequence_short(n, expected_total_sleep_time):
31283123
func = FunctionToOptimize(function_name="accurate_sleepfunc", parents=[], file_path=code_path)
31293124
os.chdir(run_cwd)
31303125
success, new_test = inject_profiling_into_existing_test(
3131-
test_path, [CodePosition(8, 13)], func, project_root_path, "pytest", mode=TestingMode.PERFORMANCE
3126+
test_path, [CodePosition(8, 13)], func, project_root_path, mode=TestingMode.PERFORMANCE
31323127
)
31333128
os.chdir(original_cwd)
31343129

@@ -3245,7 +3240,7 @@ def test_sleepfunc_sequence_short(self, n, expected_total_sleep_time):
32453240
func = FunctionToOptimize(function_name="accurate_sleepfunc", parents=[], file_path=code_path)
32463241
os.chdir(run_cwd)
32473242
success, new_test = inject_profiling_into_existing_test(
3248-
test_path, [CodePosition(12, 17)], func, project_root_path, "unittest", mode=TestingMode.PERFORMANCE
3243+
test_path, [CodePosition(12, 17)], func, project_root_path, mode=TestingMode.PERFORMANCE
32493244
)
32503245
os.chdir(original_cwd)
32513246

0 commit comments

Comments
 (0)