Spaces:
Running
Running
File size: 1,053 Bytes
f249c51 a79668c | 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 | 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
|