add test in instrumentation

This commit is contained in:
Kevin Turcios 2025-02-20 19:41:17 -05:00
parent f40c388ef6
commit f164fd2431
2 changed files with 7 additions and 4 deletions

View file

@ -3,6 +3,7 @@ class BubbleSorter:
self.x = x self.x = x
def sorter(self, arr): def sorter(self, arr):
print("codeflash stdout : BubbleSorter.sorter() called")
for i in range(len(arr)): for i in range(len(arr)):
for j in range(len(arr) - 1): for j in range(len(arr) - 1):
if arr[j] > arr[j + 1]: if arr[j] > arr[j + 1]:

View file

@ -168,6 +168,8 @@ def test_sort():
pytest_max_loops=1, pytest_max_loops=1,
testing_time=0.1, testing_time=0.1,
) )
assert "codeflash stdout: Sorting list" in test_results[0].stdout
assert "result: [0, 1, 2, 3, 4, 5]" in test_results[0].stdout
assert test_results[0].id.function_getting_tested == "sorter" assert test_results[0].id.function_getting_tested == "sorter"
assert test_results[0].id.iteration_id == "1_0" assert test_results[0].id.iteration_id == "1_0"
assert test_results[0].id.test_class_name is None assert test_results[0].id.test_class_name is None
@ -179,7 +181,8 @@ def test_sort():
assert test_results[0].runtime > 0 assert test_results[0].runtime > 0
assert test_results[0].did_pass assert test_results[0].did_pass
assert test_results[0].return_value == ([0, 1, 2, 3, 4, 5],) assert test_results[0].return_value == ([0, 1, 2, 3, 4, 5],)
assert "codeflash stdout: Sorting list" in test_results[1].stdout
assert "result: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]" in test_results[1].stdout
assert test_results[1].id.function_getting_tested == "sorter" assert test_results[1].id.function_getting_tested == "sorter"
assert test_results[1].id.iteration_id == "4_0" assert test_results[1].id.iteration_id == "4_0"
assert test_results[1].id.test_class_name is None assert test_results[1].id.test_class_name is None
@ -340,13 +343,11 @@ def test_sort():
pytest_max_loops=1, pytest_max_loops=1,
testing_time=0.1, testing_time=0.1,
) )
assert len(test_results) == 4 assert len(test_results) == 4
assert test_results[0].id.function_getting_tested == "BubbleSorter.__init__" assert test_results[0].id.function_getting_tested == "BubbleSorter.__init__"
assert test_results[0].id.test_function_name == "test_sort" assert test_results[0].id.test_function_name == "test_sort"
assert test_results[0].did_pass assert test_results[0].did_pass
assert test_results[0].return_value[0] == {"x": 0} assert test_results[0].return_value[0] == {"x": 0}
assert test_results[1].id.function_getting_tested == "BubbleSorter.sorter" assert test_results[1].id.function_getting_tested == "BubbleSorter.sorter"
assert test_results[1].id.iteration_id == "2_0" assert test_results[1].id.iteration_id == "2_0"
assert test_results[1].id.test_class_name is None assert test_results[1].id.test_class_name is None
@ -358,7 +359,8 @@ def test_sort():
assert test_results[1].runtime > 0 assert test_results[1].runtime > 0
assert test_results[1].did_pass assert test_results[1].did_pass
assert test_results[1].return_value == ([0, 1, 2, 3, 4, 5],) assert test_results[1].return_value == ([0, 1, 2, 3, 4, 5],)
assert "codeflash stdout : BubbleSorter.sorter() called" in test_results[1].stdout
assert compare_test_results(test_results, test_results)
assert test_results[2].id.function_getting_tested == "BubbleSorter.__init__" assert test_results[2].id.function_getting_tested == "BubbleSorter.__init__"
assert test_results[2].id.test_function_name == "test_sort" assert test_results[2].id.test_function_name == "test_sort"
assert test_results[2].did_pass assert test_results[2].did_pass