diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index eecbc00154..88bb8098ef 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -15,7 +15,7 @@ inputs: pytest-args: description: 'Additional arguments to pass to pytest' required: false - default: '--mpl -W error::metpy.deprecation.MetpyDeprecationWarning' + default: '--mpl -W error::metpy.deprecation.MetpyDeprecationWarning -n auto --cov --cov-report=xml' runs: using: composite steps: @@ -30,10 +30,8 @@ runs: # By running coverage in "parallel" mode and "combining", we can clean up the path names run: | set -e -o pipefail - python -m coverage run -p -m pytest ${{ inputs.pytest-args }} tests/ 2>&1 | tee tests-${{ inputs.key }}.log - python -m coverage combine - python -m coverage report - python -m coverage xml + python -m pytest ${{ inputs.pytest-args }} tests/ 2>&1 | tee tests-${{ inputs.key }}.log + - name: Run doctests if: ${{ inputs.run-doctests == 'true' }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d3f06f5bf5..b37d4483b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -301,7 +301,14 @@ To run these tests, use: ```sh pytest --mpl -```` +``` + +To run tests in parallel, use `-n ` or `-n auto` (using `pytest-xdist`): + +```sh +pytest --mpl -n auto +pytest --mpl -n 2 +``` When adding new image comparison tests, start by creating the baseline images for the tests: diff --git a/ci-dev/test_requirements.txt b/ci-dev/test_requirements.txt index e3ba23ed7f..01e3b97749 100644 --- a/ci-dev/test_requirements.txt +++ b/ci-dev/test_requirements.txt @@ -1,5 +1,8 @@ + packaging==26.0 pytest==9.0.0 +pytest-cov==6.2.1 pytest-mpl==0.18.0 +pytest-xdist==3.8.0 coverage==7.13.0 -vcrpy==8.1.0 +vcrpy==8.1.0 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 7ad5b26abc..9e70377e40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,8 @@ test = [ "netCDF4", "packaging>=21.0", "pytest>=7.0", + "pytest-xdist", + "pytest-cov", "pytest-mpl", "vcrpy>=4.3.1" ]