Conversation
There was a problem hiding this comment.
Pull request overview
This pull request enhances the test suite's reliability and enables parallel test execution by introducing pytest-xdist. The changes add proper test grouping to prevent race conditions when tests manipulate shared resources or spawn processes, and include minor improvements to test fixtures.
Key changes:
- Added pytest-xdist and pytest-cov dependencies to enable parallel test execution across multiple workers
- Configured tox.ini to run tests with 3 workers using the loadgroup distribution strategy
- Grouped tests that spawn processes or manipulate shared resources (static files, sockets) to run on the same worker, preventing conflicts
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| setup.py | Added pytest-xdist and pytest-cov to test requirements for parallel execution and coverage reporting |
| tox.ini | Updated to use pytest-xdist with 3 workers and loadgroup distribution; added xdist_group marker documentation |
| tests/worker/conftest.py | Added hook to automatically group all worker tests under process_spawning group |
| tests/test_url_for_static.py | Added xdist_group marker for static_files group |
| tests/test_unix_socket.py | Combined existing skipif marker with xdist_group marker for unix_socket group |
| tests/test_tls.py | Added xdist_group markers to specific process-spawning tests; updated tests to use dynamic port fixture |
| tests/test_static_directory.py | Added xdist_group marker for static_files group |
| tests/test_static.py | Added xdist_group marker for static_files group; improved fixture cleanup to remove existing files before creation |
| tests/test_signal_handlers.py | Added xdist_group marker for process_spawning group |
| tests/test_routes.py | Changed hardcoded port to avoid conflicts |
| tests/test_multiprocessing.py | Added xdist_group marker for process_spawning group |
| tests/test_late_adds.py | Added xdist_group marker for process_spawning group |
| tests/test_keep_alive_timeout.py | Added xdist_group marker for keep_alive_timeout group |
| tests/test_config.py | Updated test to use dynamic port fixture |
| tests/test_app.py | Updated test to use dynamic port fixture |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3107 +/- ##
=========================================
Coverage 87.683% 87.683%
=========================================
Files 104 104
Lines 7778 7778
Branches 1236 1236
=========================================
Hits 6820 6820
Misses 662 662
Partials 296 296 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This pull request improves the test suite's reliability and parallelization by introducing pytest-xdist for parallel test execution, organizing tests into logical groups to avoid conflicts, and making minor test improvements. The changes ensure that tests which spawn processes or manipulate shared resources are grouped together, preventing race conditions and flaky test failures.
Test suite parallelization and grouping:
pytest-xdistandpytest-covto test requirements insetup.pyto enable parallel test execution and coverage reporting.tox.inito run tests in parallel using three workers and theloadgroupdistribution strategy, and documented the newxdist_groupmarker. [1] [2]Test grouping to avoid conflicts:
pytestmark = pytest.mark.xdist_group(...)to multiple test files (such astest_keep_alive_timeout.py,test_multiprocessing.py,test_signal_handlers.py,test_static.py,test_static_directory.py,test_url_for_static.py, andtest_unix_socket.py) to ensure tests that manipulate processes, static files, or sockets are run together on the same worker. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]pytest_collection_modifyitemshook intests/worker/conftest.pyto automatically group all worker-related tests under theprocess_spawninggroup.Test improvements and cleanup:
portfixture instead of hardcoded ports, improving test reliability and reducing port conflicts. [1] [2] [3] [4] [5] [6]