Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
Omit tests from coverage report (#384)
Browse files Browse the repository at this point in the history
Add a `.coveragerc` file to configure the coverage report. 
This drops the coverage value but it's more realistic now.
Configure TravisCI to use the Makefile to run the tests and produce the
coverage report.
  • Loading branch information
leouieda committed Mar 18, 2017
1 parent 2725e9e commit c0e2645
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 42 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
omit =
*/_version.py
*/_our_duecredit.py
*/fatiando/__init__.py
*/tests/*
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ spelling-store-unknown-words=no
[BASIC]

# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,x,y,z,x1,x2,y1,y2,z1,z2,xp,yp,zp,xc,yc,zc,nx,ny,nc,dx,dy,dz,dt,p1,p2,r1,r2,w,e,s,n,_
good-names=i,j,k,x,y,z,x1,x2,y1,y2,z1,z2,xp,yp,zp,xc,yc,zc,nx,ny,nz,dx,dy,dz,dt,p1,p2,r1,r2,w,e,s,n,_

# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ install:
- pip install dist/fatiando-*.tar.gz

script:
- bash ci/run-tests.sh
- if [ "$COVERAGE" == "true" ]; then make coverage; else make test; fi
- make pep8
# Check for Python 3 compatibility regressions
- make check3
Expand Down
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Build, package, test, and clean Fatiando

TESTDIR=tmp-test-dir-with-unique-name
PEP8ARGS=--show-source --ignore=W503,E226,E241,E731 --exclude=_version.py
TESTDIR=tmp-test-dir
COVDIR=tmp-cov-dir
PYTEST_ARGS=--doctest-modules -v --pyargs
PYTEST_COV_ARGS=--cov-config=../.coveragerc --cov-report=term-missing

help:
@echo "Commands:"
Expand All @@ -25,17 +27,16 @@ cython:

test:
# Run a tmp folder to make sure the tests are run on the installed version
# of Fatiando
mkdir -p $(TESTDIR)
cd $(TESTDIR); python -c "import fatiando; fatiando.test()"
cd $(TESTDIR); python -c "import fatiando; fatiando.test(verbose=True)"
rm -r $(TESTDIR)

coverage:
# Run a tmp folder to make sure the tests are run on the installed version
# of Fatiando
mkdir -p $(TESTDIR)
cd $(TESTDIR); python -c "import fatiando; fatiando.test(coverage=True)"
rm -r $(TESTDIR)
mkdir -p $(COVDIR)
cd $(COVDIR); pytest $(PYTEST_COV_ARGS) --cov=fatiando $(PYTEST_ARGS) fatiando
cp $(COVDIR)/.coverage* .
rm -r $(COVDIR)

pep8:
flake8 fatiando gallery setup.py
Expand All @@ -59,4 +60,4 @@ clean:
rm -rvf crust2.tar.gz cookbook/crust2.tar.gz
rm -rvf bouguer_alps_egm08.grd cookbook/bouguer_alps_egm08.grd
rm -rvf *.gdf cookbook/*.gdf
rm -rvf $(TESTDIR)
rm -rvf $(TESTDIR) $(COVDIR)
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ install:


test_script:
- ps: mkdir -p tmp; cd tmp; python -c "import fatiando; print('Installed:', fatiando.__file__, 'and', fatiando.__version__); fatiando.test(verbose=True)"
- ps: mkdir -p tmp; cd tmp; python -c "import fatiando; print('Installed:', fatiando.__file__, 'and', fatiando.__version__); fatiando.test()"
28 changes: 0 additions & 28 deletions ci/run-tests.sh

This file was deleted.

3 changes: 1 addition & 2 deletions fatiando/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def test(doctest=True, verbose=False, coverage=False):
args.append('-v')
if coverage:
args.append('--cov=fatiando')
args.append('--cov-report')
args.append('term-missing')
args.append('--cov-report=term-missing')
if doctest:
args.append('--doctest-modules')
args.append('--pyargs')
Expand Down

0 comments on commit c0e2645

Please sign in to comment.