From af4f91c8f83105173c4dc5bd2201c1d3acb1ef1f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 03:35:08 +0000 Subject: [PATCH 1/2] Initial plan From 62f4fc431538ce24514702ea564f12b7dac22310 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 03:50:58 +0000 Subject: [PATCH 2/2] Enable parallel pytest execution with pytest-xdist (issue #356) Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com> --- .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ README.md | 20 +++++++------------- pyproject.toml | 3 +++ 3 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..5d927253 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + permissions: + contents: read + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Install dependencies + run: pip install httpx python-dotenv pytest pytest-mock pytest-xdist + + - name: Run tests in parallel + run: pytest tests/ -n auto -v diff --git a/README.md b/README.md index 163a56ee..35b73e22 100644 --- a/README.md +++ b/README.md @@ -126,34 +126,25 @@ This project includes a comprehensive test suite to ensure code quality and corr ### Running Tests -**Basic test execution:** +**Basic test execution (runs in parallel by default):** ```bash # Install dev dependencies first pip install pytest pytest-mock pytest-xdist -# Run all tests +# Run all tests (parallel execution is on by default via pyproject.toml) pytest tests/ -``` - -**Parallel test execution (recommended):** -```bash -# Run tests in parallel using all available CPU cores -pytest tests/ -n auto # Run with specific number of workers pytest tests/ -n 4 ``` -**Note on parallel execution:** The test suite is currently small (~78 tests, <1s execution time), so parallel execution overhead may result in longer wall-clock time compared to sequential execution. However, pytest-xdist is included for: -- **Test isolation verification** - Ensures tests don't share state -- **Future scalability** - As the test suite grows, parallel execution will provide significant speedups -- **CI optimization** - May benefit from parallelization in CI environments with different characteristics +Parallel execution is enabled by default via `addopts = "-n auto"` in `pyproject.toml`, so every `pytest` invocation automatically uses all available CPU cores. ### Development Workflow For active development with frequent test runs: ```bash -# Run tests sequentially (faster for small test suites) +# Run tests (parallel by default) pytest tests/ -v # Run specific test file @@ -161,6 +152,9 @@ pytest tests/test_security.py -v # Run tests matching pattern pytest tests/ -k "test_validation" -v + +# Override parallel execution for a single sequential run +pytest tests/ -n0 -v ``` ## Release Process diff --git a/pyproject.toml b/pyproject.toml index 484682a8..66217a5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,3 +16,6 @@ dev = [ "pytest-xdist>=3.0.0", "pytest-benchmark>=4.0.0", ] + +[tool.pytest.ini_options] +addopts = "-n auto"