diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index 3f3100faba9..16bb75c8ac1 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 c8406a5d25c..2c0ef59a5b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -300,7 +300,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 7999783ae72..7ccbe29219f 100644 --- a/ci-dev/test_requirements.txt +++ b/ci-dev/test_requirements.txt @@ -1,5 +1,7 @@ packaging==25.0 pytest==8.4.0 +pytest-cov==6.2.1 pytest-mpl==0.17.0 +pytest-xdist==3.8.0 coverage==7.10.2 vcrpy==7.0.0 diff --git a/pyproject.toml b/pyproject.toml index 33bf3be94c4..9a4cc6032b8 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" ]