Skip to content

Commit 2fa1abc

Browse files
committed
adress review
Update pyproject.toml Update test_instrument_tests.py Update test_instrument_all_and_run.py missing test
1 parent 8efafe5 commit 2fa1abc

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

124123
[tool.poetry.build]
125124
script = "codeflash/update_license_version.py"

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
@@ -178,6 +178,7 @@ def test_single_element_list():
178178
testing_time=0.1,
179179
)
180180
assert test_results[0].id.function_getting_tested == "sorter"
181+
assert test_results[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
181182
assert test_results[0].id.test_function_name == "test_single_element_list"
182183
assert test_results[0].did_pass
183184
assert test_results[0].return_value[1]["arr"] == [42]
@@ -221,6 +222,7 @@ def sorter(self, arr):
221222
test_results, test_results_mutated_attr
222223
) # Without codeflash capture, the init state was not verified, and the results are verified as correct even with the attribute mutated
223224

225+
assert test_results_mutated_attr[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
224226
finally:
225227
fto_path.write_text(original_code, "utf-8")
226228
test_path.unlink(missing_ok=True)
@@ -321,6 +323,7 @@ def test_single_element_list():
321323
assert test_results[0].id.test_function_name == "test_single_element_list"
322324
assert test_results[0].did_pass
323325
assert test_results[0].return_value[0] == {"x": 0}
326+
assert test_results[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
324327

325328
# Verify function_to_optimize result
326329
assert test_results[1].id.function_getting_tested == "sorter"
@@ -390,6 +393,7 @@ def sorter(self, arr):
390393
assert test_results_mutated_attr[0].id.function_getting_tested == "BubbleSorter.__init__"
391394
assert test_results_mutated_attr[0].return_value[0] == {"x": 1}
392395
assert test_results_mutated_attr[0].verification_type == VerificationType.INIT_STATE_FTO
396+
assert test_results_mutated_attr[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
393397
assert not compare_test_results(
394398
test_results, test_results_mutated_attr
395399
) # The test should fail because the instance attribute was mutated
@@ -441,6 +445,7 @@ def sorter(self, arr):
441445
assert test_results_new_attr[0].id.function_getting_tested == "BubbleSorter.__init__"
442446
assert test_results_new_attr[0].return_value[0] == {"x": 0, "y": 2}
443447
assert test_results_new_attr[0].verification_type == VerificationType.INIT_STATE_FTO
448+
assert test_results_new_attr[0].stdout == "codeflash stdout : BubbleSorter.sorter() called"
444449
# assert test_results_new_attr[1].return_value[1]["self"].x == 0 TODO: add self as input
445450
# assert test_results_new_attr[1].return_value[1]["self"].y == 2 TODO: add self as input
446451
assert compare_test_results(

0 commit comments

Comments
 (0)