Skip to content

Commit 8b9f37c

Browse files
committed
modify existing test
1 parent 1753e16 commit 8b9f37c

File tree

2 files changed

+28
-57
lines changed

2 files changed

+28
-57
lines changed

tests/scripts/end_to_end_test_bubblesort_blacklist_arg_pytest.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/scripts/end_to_end_test_topological_sort.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
import os
22
import pathlib
3+
import tomlkit
34

45
from end_to_end_test_utilities import CoverageExpectation, TestConfig, run_codeflash_command, run_with_retries
56

67

78
def run_test(expected_improvement_pct: int) -> bool:
8-
config = TestConfig(
9-
file_path="topological_sort.py",
10-
function_name="Graph.topologicalSort",
11-
test_framework="pytest",
12-
min_improvement_x=0.05,
13-
coverage_expectations=[
14-
CoverageExpectation(
15-
function_name="Graph.topologicalSort", expected_coverage=100.0, expected_lines=[24, 25, 26, 27, 28, 29]
16-
)
17-
],
18-
)
19-
cwd = (pathlib.Path(__file__).parent.parent.parent / "code_to_optimize").resolve()
20-
return run_codeflash_command(cwd, config, expected_improvement_pct)
9+
try:
10+
# Modify Pyproject file
11+
with pathlib.Path.open((pathlib.Path(__file__).parent.parent.parent / "pyproject.toml").resolve(), encoding="utf-8") as f:
12+
original_content = f.read()
13+
data = tomlkit.parse(original_content)
14+
data["tool"]["pytest"] = {}
15+
data["tool"]["pytest"]["ini_options"] = {}
16+
data["tool"]["pytest"]["ini_options"]["addopts"] = ["-n=auto", "-n", "1", "-n 1", "-n 1", "-n auto"]
17+
with pathlib.Path.open((pathlib.Path(__file__).parent.parent.parent / "pyproject.toml").resolve(), "w", encoding="utf-8") as f:
18+
f.write(tomlkit.dumps(data))
19+
config = TestConfig(
20+
file_path="topological_sort.py",
21+
function_name="Graph.topologicalSort",
22+
test_framework="pytest",
23+
min_improvement_x=0.05,
24+
coverage_expectations=[
25+
CoverageExpectation(
26+
function_name="Graph.topologicalSort", expected_coverage=100.0, expected_lines=[24, 25, 26, 27, 28, 29]
27+
)
28+
],
29+
)
30+
cwd = (pathlib.Path(__file__).parent.parent.parent / "code_to_optimize").resolve()
31+
return run_codeflash_command(cwd, config, expected_improvement_pct)
32+
finally:
33+
with pathlib.Path.open(pathlib.Path("pyproject.toml"), "w", encoding="utf-8") as f:
34+
f.write(original_content)
35+
2136

2237

2338
if __name__ == "__main__":

0 commit comments

Comments
 (0)