test_runner_app.py is a Flask-based web application that provides a browser UI for discovering, running, and monitoring pytest tests in real time. Instead of running pytest -v --html=report.html from the terminal, users can do everything visually from a web page.
It runs on port 5001 separately from the Petstore API (which runs on port 5000).
# Make sure the virtual environment is activated
venv\Scripts\activate
# Start the test runner UI
python test_runner_app.pyThe browser will automatically open http://localhost:5001 when started.
| URL | Description |
|---|---|
http://localhost:5001/ |
Main test runner UI |
http://localhost:5001/report |
Pytest HTML report viewer |
A custom pytest plugin that hooks into pytest's internal reporting system.
pytest_runtest_logreport— fires after each test runs and captures its result (passed,failed,skipped) and puts it into a shared queuepytest_sessionfinish— fires when all tests are done and sends adonesignal to the queue
This is what enables real-time updates in the browser.
Runs pytest in a background thread so the Flask server stays responsive while tests are executing.
- Accepts a list of selected test node IDs
- Injects the
LiveTestPluginso results are streamed live - Also generates
report.htmlautomatically after each run
Serves the main UI page (templates/index.html) where users can see and run tests.
Uses subprocess to run pytest --collect-only and returns a JSON list of all discovered test IDs.
Example response:
[
"test_pet.py::test_pet_schema",
"test_pet.py::test_find_by_status_200[available]",
"test_store.py::test_patch_order_by_id[sold]"
]Accepts a list of selected test IDs and starts running them in a background thread.
Request body:
{ "tests": ["test_pet.py::test_pet_schema"] }Response:
{ "status": "started" }Returns 400 if tests are already running.
A Server-Sent Events (SSE) endpoint that streams live test results to the browser as they complete.
Event types:
| Type | Meaning |
|---|---|
result |
A test finished — includes test name and status |
done |
All tests completed |
heartbeat |
Keep-alive ping every second |
Example event:
data: {"type": "result", "test": "test_pet.py::test_pet_schema", "status": "passed"}
Serves the report viewer page (templates/report_page.html) which embeds the pytest HTML report in an iframe.
Serves the raw report.html file generated by pytest. Returns 404 if no report exists yet.
Serves the CSS and assets needed by report.html so it renders correctly in the browser.
| Feature | Description |
|---|---|
| Summary Cards | Shows total / passed / failed / skipped / pending counts |
| Test List | All discovered tests displayed with checkboxes |
| Select All / Deselect All | Bulk checkbox controls |
| Run Selected | Runs only the checked tests |
| Live Status Badges | Each test badge updates in real time: pending → running → passed/failed/skipped |
| Progress Bar | Visual progress as tests complete |
| Status Bar | Text feedback e.g. "Running... 3/7 completed" |
| View Report | Opens the full pytest HTML report in a new tab |
Browser → GET /api/tests → Collect all tests
Browser → POST /api/run → Start tests in background thread
Browser → GET /api/stream (SSE) → Receive live results
Browser → GET /report → View full HTML report
All dependencies are already included in the project's install command:
pip install flask pytest