Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab100f4

Browse files
committed
Merge pull request #4678 from jenshnielsen/tst_coveralls
TST: Enable coveralls/codecov code coverage
2 parents 6dd4103 + 8f3dccb commit ab100f4

File tree

5 files changed

+44
-11
lines changed

5 files changed

+44
-11
lines changed

.coveragerc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[run]
2+
source=matplotlib
3+
[report]
4+
omit =
5+
lib/matplotlib/tests/*
6+
lib/matplotlib/testing/*
7+
8+
exclude_lines =
9+
raise NotImplemented

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ result_images
7373

7474
*.swp
7575
setup.cfg
76+
77+
# Coverage generated files #
78+
############################
79+
80+
.coverage
81+
.coverage.*
82+
cover/

.travis.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ env:
2929
- PANDAS=
3030
- NPROC=2
3131
- TEST_ARGS=--no-pep8
32+
- NOSE_ARGS="--processes=$NPROC --process-timeout=300"
3233

3334
language: python
3435

@@ -38,7 +39,7 @@ matrix:
3839
env: MOCK=mock NUMPY=numpy==1.6
3940
- python: 3.4
4041
- python: 3.5
41-
env: PANDAS=pandas
42+
env: PANDAS=pandas NOSE_ARGS=--with-coverage
4243
- python: 3.5
4344
env: TEST_ARGS=--pep8
4445
- python: 2.7
@@ -67,19 +68,17 @@ install:
6768
pip install $PRE python-dateutil $NUMPY pyparsing!=2.0.4 pillow sphinx!=1.3.0;
6869
fi
6970
# Always install from pypi
70-
- pip install $PRE pep8 cycler
71-
- 'pip install https://github.com/tacaswell/nose/zipball/mnt_py36_compat#egg=nose'
71+
- pip install $PRE pep8 cycler coveralls coverage
72+
- 'pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose'
7273

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

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

9998
script:
10099
# The number of processes is hardcoded, because using too many causes the
101100
# Travis VM to run out of memory (since so many copies of inkscape and
102101
# ghostscript are running at the same time).
103102
- echo Testing using $NPROC processes
103+
- echo The following args are passed to nose $NOSE_ARGS
104104
- |
105105
if [[ $BUILD_DOCS == false ]]; then
106106
export MPL_REPO_DIR=$PWD # needed for pep8-conformance test of the examples
107-
gdb -return-child-result -batch -ex r -ex bt --args python tests.py --processes=$NPROC --process-timeout=300 $TEST_ARGS
107+
gdb -return-child-result -batch -ex r -ex bt --args python tests.py $NOSE_ARGS $TEST_ARGS
108108
else
109109
cd doc
110110
python make.py html --small --warningsaserrors
@@ -165,3 +165,6 @@ after_success:
165165
fi
166166
fi
167167
fi
168+
if [[ $NOSE_ARGS="--with-coverage" ]]; then
169+
coveralls
170+
fi

lib/matplotlib/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,14 @@ def _get_extra_test_plugins():
15291529
return [KnownFailure, attrib.Plugin]
15301530

15311531

1532-
def test(verbosity=1):
1532+
def _get_nose_env():
1533+
env = {'NOSE_COVER_PACKAGE': 'matplotlib',
1534+
'NOSE_COVER_HTML': 1,
1535+
'NOSE_COVER_NO_PRINT': 1}
1536+
return env
1537+
1538+
1539+
def test(verbosity=1, coverage=False):
15331540
"""run the matplotlib test suite"""
15341541
_init_tests()
15351542

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

1563+
env = _get_nose_env()
1564+
if coverage:
1565+
env['NOSE_WITH_COVERAGE'] = 1
1566+
15561567
success = nose.run(
15571568
defaultTest=default_test_modules,
15581569
config=config,
1570+
env=env,
15591571
)
15601572
finally:
15611573
if old_backend.lower() != 'agg':

tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
def run(extra_args):
2424
from nose.plugins import multiprocess
2525

26+
env = matplotlib._get_nose_env()
27+
2628
matplotlib._init_tests()
2729

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

3436
nose.main(addplugins=[x() for x in plugins],
3537
defaultTest=default_test_modules,
36-
argv=sys.argv + extra_args)
37-
38+
argv=sys.argv + extra_args,
39+
env=env)
3840

3941
if __name__ == '__main__':
4042
extra_args = []

0 commit comments

Comments
 (0)