Skip to content

Commit dcf9384

Browse files
committed
adress review
Update pyproject.toml Update test_instrument_tests.py Update test_instrument_all_and_run.py missing test
1 parent bb1bbf9 commit dcf9384

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ types-gevent = "^24.11.0.20241230"
119119
types-greenlet = "^3.1.0.20241221"
120120
types-pexpect = "^4.9.0.20241208"
121121
types-unidiff = "^0.7.0.20240505"
122-
sqlalchemy = "^2.0.38"
123122
uv = ">=0.6.2"
124123

125124
[tool.poetry.build]

tests/test_instrument_all_and_run.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_sort():
174174
175175
codeflash stdout: Sorting list
176176
result: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]"""
177-
assert out_str == test_results[0].stdout.strip()
177+
assert out_str == test_results[0].stdout
178178
assert test_results[0].id.function_getting_tested == "sorter"
179179
assert test_results[0].id.iteration_id == "1_0"
180180
assert test_results[0].id.test_class_name is None
@@ -380,12 +380,8 @@ def test_sort():
380380
assert test_results[1].runtime > 0
381381
assert test_results[1].did_pass
382382
assert test_results[1].return_value == ([0, 1, 2, 3, 4, 5],)
383-
out_str = """
384-
codeflash stdout : BubbleSorter.sorter() called
385-
386-
387-
codeflash stdout : BubbleSorter.sorter() called"""
388-
assert test_results[1].stdout.strip() == out_str.strip()
383+
out_str = """codeflash stdout : BubbleSorter.sorter() called\n\n\ncodeflash stdout : BubbleSorter.sorter() called"""
384+
assert test_results[1].stdout == out_str
389385
assert compare_test_results(test_results, test_results)
390386
assert test_results[2].id.function_getting_tested == "BubbleSorter.__init__"
391387
assert test_results[2].id.test_function_name == "test_sort"

tests/test_instrument_tests.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,9 @@ def test_sort_parametrized(input, expected_output):
700700
assert test_results_perf[1].runtime > 0
701701
assert test_results_perf[1].did_pass
702702

703-
assert "codeflash stdout: Sorting list" in test_results_perf[1].stdout
704-
assert "result: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]" in test_results_perf[1].stdout
703+
out_str = """codeflash stdout: Sorting list
704+
result: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]"""
705+
assert out_str == test_results_perf[1].stdout
705706

706707
assert test_results_perf[2].id.function_getting_tested == "sorter"
707708
assert test_results_perf[2].id.iteration_id == "0_2"
@@ -1240,8 +1241,15 @@ def test_sort():
12401241
assert test_results[0].runtime > 0
12411242
assert test_results[0].did_pass
12421243
assert test_results[0].return_value is None
1243-
assert "codeflash stdout: Sorting list" in test_results[0].stdout
1244-
assert "result: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]" in test_results[0].stdout
1244+
out_str = """codeflash stdout: Sorting list
1245+
result: [0, 1, 2, 3, 4, 5]
1246+
1247+
codeflash stdout: Sorting list
1248+
result: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
1249+
1250+
codeflash stdout: Sorting list
1251+
result: [0, 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, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]"""
1252+
assert test_results[1].stdout == out_str
12451253
assert test_results[1].id.function_getting_tested == "sorter"
12461254
assert test_results[1].id.iteration_id == "2_2_1"
12471255
assert test_results[1].id.test_class_name is None

tests/test_instrumentation_run_results_aiservice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def test_single_element_list():
179179
testing_time=0.1,
180180
)
181181
assert test_results[0].id.function_getting_tested == "sorter"
182+
assert test_results[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
182183
assert test_results[0].id.test_function_name == "test_single_element_list"
183184
assert test_results[0].did_pass
184185
assert test_results[0].return_value[1]["arr"] == [42]
@@ -222,6 +223,7 @@ def sorter(self, arr):
222223
test_results, test_results_mutated_attr
223224
) # Without codeflash capture, the init state was not verified, and the results are verified as correct even with the attribute mutated
224225

226+
assert test_results_mutated_attr[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
225227
finally:
226228
fto_path.write_text(original_code, "utf-8")
227229
test_path.unlink(missing_ok=True)
@@ -322,6 +324,7 @@ def test_single_element_list():
322324
assert test_results[0].id.test_function_name == "test_single_element_list"
323325
assert test_results[0].did_pass
324326
assert test_results[0].return_value[0] == {"x": 0}
327+
assert test_results[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
325328

326329
# Verify function_to_optimize result
327330
assert test_results[1].id.function_getting_tested == "sorter"
@@ -391,6 +394,7 @@ def sorter(self, arr):
391394
assert test_results_mutated_attr[0].id.function_getting_tested == "BubbleSorter.__init__"
392395
assert test_results_mutated_attr[0].return_value[0] == {"x": 1}
393396
assert test_results_mutated_attr[0].verification_type == VerificationType.INIT_STATE_FTO
397+
assert test_results_mutated_attr[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
394398
assert not compare_test_results(
395399
test_results, test_results_mutated_attr
396400
) # The test should fail because the instance attribute was mutated
@@ -442,6 +446,7 @@ def sorter(self, arr):
442446
assert test_results_new_attr[0].id.function_getting_tested == "BubbleSorter.__init__"
443447
assert test_results_new_attr[0].return_value[0] == {"x": 0, "y": 2}
444448
assert test_results_new_attr[0].verification_type == VerificationType.INIT_STATE_FTO
449+
assert test_results_new_attr[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
445450
# assert test_results_new_attr[1].return_value[1]["self"].x == 0 TODO: add self as input
446451
# assert test_results_new_attr[1].return_value[1]["self"].y == 2 TODO: add self as input
447452
assert compare_test_results(

0 commit comments

Comments
 (0)