ai-code-review-agent / tests /test_pytest_runner.py
Padmanav's picture
fix: add missing 'success' key to run_tests return dict
9544ac0
Raw
History Blame Contribute Delete
1.05 kB
import os
import tempfile
from app.tools.pytest_runner import run_tests
def test_run_tests_no_tests():
with tempfile.TemporaryDirectory() as tmpdir:
result = run_tests(tmpdir)
assert isinstance(result["passed"], int)
assert isinstance(result["failed"], int)
assert isinstance(result["errors"], int)
assert "output" in result
def test_run_tests_with_passing_test():
with tempfile.TemporaryDirectory() as tmpdir:
test_path = os.path.join(tmpdir, "test_sample.py")
with open(test_path, "w") as f:
f.write("def test_always_passes():\n assert 1 + 1 == 2\n")
result = run_tests(tmpdir)
assert result["passed"] >= 1
assert result["success"] is True
def test_run_tests_with_failing_test():
with tempfile.TemporaryDirectory() as tmpdir:
test_path = os.path.join(tmpdir, "test_sample.py")
with open(test_path, "w") as f:
f.write("def test_always_fails():\n assert 1 == 2\n")
result = run_tests(tmpdir)
assert result["failed"] >= 1