From 6e3ae4bebba99e380c243ed27c4270b24e390b47 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Fri, 12 Dec 2025 23:07:35 +0100 Subject: [PATCH] fix: add pytest-json-report dependency and improve error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- app/services/test_runner_service.py | 7 ++++--- requirements-test.txt | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/services/test_runner_service.py b/app/services/test_runner_service.py index 280f0d76..8bfc1e5e 100644 --- a/app/services/test_runner_service.py +++ b/app/services/test_runner_service.py @@ -96,14 +96,15 @@ class TestRunnerService: report = json.load(f) self._process_json_report(db, test_run, report) - except FileNotFoundError: - # Fallback to parsing stdout + except (FileNotFoundError, json.JSONDecodeError) as e: + # 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) finally: # Clean up temp file try: Path(json_report_path).unlink() - except: + except Exception: pass # Set final status diff --git a/requirements-test.txt b/requirements-test.txt index 628612da..324900f8 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -4,6 +4,7 @@ pytest>=8.3.4 pytest-cov>=6.0.0 pytest-asyncio>=0.24.0 pytest-mock>=3.14.0 +pytest-json-report>=1.5.0 httpx>=0.28.1 faker>=33.1.0 pytest-repeat>=0.9.4