fix: add pytest-json-report dependency and improve error handling

- Add pytest-json-report to requirements-test.txt for JSON test output
- Improve error handling in test runner service to catch JSONDecodeError
  and fallback to parsing stdout when JSON report is unavailable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-12 23:07:35 +01:00
parent 213ff11c98
commit 6e3ae4bebb
2 changed files with 5 additions and 3 deletions

View File

@@ -96,14 +96,15 @@ class TestRunnerService:
report = json.load(f) report = json.load(f)
self._process_json_report(db, test_run, report) self._process_json_report(db, test_run, report)
except FileNotFoundError: except (FileNotFoundError, json.JSONDecodeError) as e:
# Fallback to parsing stdout # Fallback to parsing stdout if JSON report failed
logger.warning(f"JSON report unavailable ({e}), parsing stdout")
self._parse_pytest_output(test_run, result.stdout, result.stderr) self._parse_pytest_output(test_run, result.stdout, result.stderr)
finally: finally:
# Clean up temp file # Clean up temp file
try: try:
Path(json_report_path).unlink() Path(json_report_path).unlink()
except: except Exception:
pass pass
# Set final status # Set final status

View File

@@ -4,6 +4,7 @@ pytest>=8.3.4
pytest-cov>=6.0.0 pytest-cov>=6.0.0
pytest-asyncio>=0.24.0 pytest-asyncio>=0.24.0
pytest-mock>=3.14.0 pytest-mock>=3.14.0
pytest-json-report>=1.5.0
httpx>=0.28.1 httpx>=0.28.1
faker>=33.1.0 faker>=33.1.0
pytest-repeat>=0.9.4 pytest-repeat>=0.9.4