From 06ef3b347312604d253a3a2bdabe96ac7e1c2d08 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Tue, 29 Sep 2020 23:59:54 -0600 Subject: [PATCH] MNT: Run coverage directly instead of using pytest-cov pytest-cov ends up invoking coverage *after* the warning filter, which means coverage starts after many submodules are imported. --- .coveragerc | 10 ++++++++++ .github/workflows/tests-conda.yml | 6 +++++- .github/workflows/tests-pypi.yml | 5 ++++- .travis.yml | 5 ++++- ci/test_requirements.txt | 2 +- setup.cfg | 3 --- 6 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000000..af5e6896b29 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,10 @@ +[paths] +source = + src/ + /*/site-packages + +[run] +source = tests +source_pkgs = metpy +omit = + src/metpy/io/_nexrad_msgs/parse_spec.py diff --git a/.github/workflows/tests-conda.yml b/.github/workflows/tests-conda.yml index b83e80ebe6a..e26b56f3375 100644 --- a/.github/workflows/tests-conda.yml +++ b/.github/workflows/tests-conda.yml @@ -85,9 +85,13 @@ jobs: python -m pip install --no-deps . - name: Run tests + # By running coverage in "parallel" mode and "combining", we can clean up the path names run: | export TEST_DATA_DIR=$GITHUB_WORKSPACE/staticdata - python -m pytest --mpl -W error::metpy.deprecation.MetpyDeprecationWarning --cov=metpy --cov=tests --cov-report=xml + python -m coverage run -p -m pytest --mpl -W error::metpy.deprecation.MetpyDeprecationWarning tests/ + python -m coverage combine + python -m coverage report + python -m coverage xml - name: Run doctests # Windows produces some slightly different types that causes doctests to fail diff --git a/.github/workflows/tests-pypi.yml b/.github/workflows/tests-pypi.yml index 7c73dc06079..9950c10ecf5 100644 --- a/.github/workflows/tests-pypi.yml +++ b/.github/workflows/tests-pypi.yml @@ -107,7 +107,10 @@ jobs: run: | export TEST_DATA_DIR=$GITHUB_WORKSPACE/staticdata export NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=1 - python -m pytest --mpl -W error::metpy.deprecation.MetpyDeprecationWarning --cov=metpy --cov=tests --cov-report=xml + python -m coverage run -p -m pytest --mpl -W error::metpy.deprecation.MetpyDeprecationWarning tests/ + python -m coverage combine + python -m coverage report + python -m coverage xml - name: Run doctests if: ${{ matrix.dep-versions == 'Current.txt' && matrix.no-extras != 'No Extras' }} diff --git a/.travis.yml b/.travis.yml index 0b4f2173d07..09842197af3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,7 +81,10 @@ script: false; fi; else - python -m pytest --mpl -W error::metpy.deprecation.MetpyDeprecationWarning --cov=metpy --cov=tests; + python -m coverage run -p -m pytest --mpl -W error::metpy.deprecation.MetpyDeprecationWarning tests/; + python -m coverage combine; + python -m coverage report; + python -m coverage xml; fi after_script: diff --git a/ci/test_requirements.txt b/ci/test_requirements.txt index b0f2715f8dc..74e43b0a005 100644 --- a/ci/test_requirements.txt +++ b/ci/test_requirements.txt @@ -1,4 +1,4 @@ pytest==6.1.0 -pytest-cov==2.10.1 pytest-mpl==0.11 netCDF4==1.5.4 +coverage==5.3 diff --git a/setup.cfg b/setup.cfg index 8ebfa9a41f0..ecdec2cf20d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -96,9 +96,6 @@ norecursedirs = build docs .idea doctest_optionflags = NORMALIZE_WHITESPACE mpl-results-path = test_output -[coverage:run] -omit = src/metpy/io/_nexrad_msgs/parse_spec.py,src/metpy/io/metar_parser.py - [doc8] ignore-path = docs/build,docs/api/generated,docs/_templates,docs/tutorials,docs/examples file-encoding = utf8