Skip to content

TST: Enable coveralls/codecov code coverage #4678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[run]
source=matplotlib
[report]
omit =
lib/matplotlib/tests/*
lib/matplotlib/testing/*

exclude_lines =
raise NotImplemented
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ result_images

*.swp
setup.cfg

# Coverage generated files #
############################

.coverage
.coverage.*
cover/
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ env:
- PANDAS=
- NPROC=2
- TEST_ARGS=--no-pep8
- NOSE_ARGS="--processes=$NPROC --process-timeout=300"

language: python

Expand All @@ -38,7 +39,7 @@ matrix:
env: MOCK=mock NUMPY=numpy==1.6
- python: 3.4
- python: 3.5
env: PANDAS=pandas
env: PANDAS=pandas NOSE_ARGS=--with-coverage
- python: 3.5
env: TEST_ARGS=--pep8
- python: 2.7
Expand Down Expand Up @@ -67,19 +68,17 @@ install:
pip install $PRE python-dateutil $NUMPY pyparsing!=2.0.4 pillow sphinx!=1.3.0;
fi
# Always install from pypi
- pip install $PRE pep8 cycler
- 'pip install https://github.com/tacaswell/nose/zipball/mnt_py36_compat#egg=nose'
- pip install $PRE pep8 cycler coveralls coverage
- 'pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose'

# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
# version since is it basically just a .ttf file
# The current Travis Ubuntu image is to old to search .local/share/fonts so we store fonts in .fonts

# We install ipython to use the console highlighting. From IPython 3 this depends on jsonschema and mistune.
# Neihter is installed as a dependency of IPython since they are not used by the IPython console.
- |
if [[ $BUILD_DOCS == true ]]; then
pip install $PRE numpydoc ipython jsonschema mistune
pip install $PRE numpydoc ipython
pip install -q $PRE linkchecker
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
Expand All @@ -94,17 +93,18 @@ install:
cp .travis/setup.cfg .
fi;

- python setup.py install
- pip install -e .

script:
# The number of processes is hardcoded, because using too many causes the
# Travis VM to run out of memory (since so many copies of inkscape and
# ghostscript are running at the same time).
- echo Testing using $NPROC processes
- echo The following args are passed to nose $NOSE_ARGS
- |
if [[ $BUILD_DOCS == false ]]; then
export MPL_REPO_DIR=$PWD # needed for pep8-conformance test of the examples
gdb -return-child-result -batch -ex r -ex bt --args python tests.py --processes=$NPROC --process-timeout=300 $TEST_ARGS
gdb -return-child-result -batch -ex r -ex bt --args python tests.py $NOSE_ARGS $TEST_ARGS
else
cd doc
python make.py html --small --warningsaserrors
Expand Down Expand Up @@ -165,3 +165,6 @@ after_success:
fi
fi
fi
if [[ $NOSE_ARGS="--with-coverage" ]]; then
coveralls
fi
14 changes: 13 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,14 @@ def _get_extra_test_plugins():
return [KnownFailure, attrib.Plugin]


def test(verbosity=1):
def _get_nose_env():
env = {'NOSE_COVER_PACKAGE': 'matplotlib',
'NOSE_COVER_HTML': 1,
'NOSE_COVER_NO_PRINT': 1}
return env


def test(verbosity=1, coverage=False):
"""run the matplotlib test suite"""
_init_tests()

Expand All @@ -1553,9 +1560,14 @@ def test(verbosity=1):
# a list.
multiprocess._instantiate_plugins = plugins

env = _get_nose_env()
if coverage:
env['NOSE_WITH_COVERAGE'] = 1

success = nose.run(
defaultTest=default_test_modules,
config=config,
env=env,
)
finally:
if old_backend.lower() != 'agg':
Expand Down
6 changes: 4 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
def run(extra_args):
from nose.plugins import multiprocess

env = matplotlib._get_nose_env()

matplotlib._init_tests()

# Nose doesn't automatically instantiate all of the plugins in the
Expand All @@ -33,8 +35,8 @@ def run(extra_args):

nose.main(addplugins=[x() for x in plugins],
defaultTest=default_test_modules,
argv=sys.argv + extra_args)

argv=sys.argv + extra_args,
env=env)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be done in lib/matplotlib/__init__.py:test. Probably move the definition of the environment variables to a private function in __init__.py and then get them from here and the test function.


if __name__ == '__main__':
extra_args = []
Expand Down