Skip to content

Commit

Permalink
MNT: Run coverage directly instead of using pytest-cov
Browse files Browse the repository at this point in the history
pytest-cov ends up invoking coverage *after* the warning filter, which
means coverage starts after many submodules are imported.
  • Loading branch information
dopplershift committed Sep 30, 2020
1 parent bf77d24 commit 06ef3b3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[paths]
source =
src/
/*/site-packages

[run]
source = tests
source_pkgs = metpy
omit =
src/metpy/io/_nexrad_msgs/parse_spec.py
6 changes: 5 additions & 1 deletion .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ci/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest==6.1.0
pytest-cov==2.10.1
pytest-mpl==0.11
netCDF4==1.5.4
coverage==5.3
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06ef3b3

Please sign in to comment.