Skip to content

Commit c3dc84e

Browse files
committed
Added travis and appveyor pytest builds
1 parent cd38258 commit c3dc84e

File tree

3 files changed

+100
-45
lines changed

3 files changed

+100
-45
lines changed

.coveragerc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ source=
33
matplotlib
44
mpl_toolkits
55
[report]
6-
omit =
7-
lib/matplotlib/tests/*
8-
lib/matplotlib/testing/*
9-
lib/mpl_toolkits/tests/*
10-
116
exclude_lines =
127
raise NotImplemented
8+
if __name__ == .__main__.:

.travis.yml

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,49 @@ env:
4545
- NPROC=2
4646
- TEST_ARGS=--no-pep8
4747
- NOSE_ARGS="--processes=$NPROC --process-timeout=300"
48+
- PYTEST_ARGS="-ra --timeout=300 --durations=25 --cov-report= --cov=lib" # -n $NPROC
4849
- PYTHON_ARGS=
4950
- DELETE_FONT_CACHE=
51+
- USE_PYTEST=false
52+
- PYTHONHASHSEED=0 # Workaround for pytest-xdist flaky colletion order
53+
# https://github.com/pytest-dev/pytest/issues/920
54+
# https://github.com/pytest-dev/pytest/issues/1075
5055

5156
matrix:
5257
include:
58+
#- python: 2.7
59+
# env: MOCK=mock NUMPY=numpy==1.6
60+
#- python: 3.4
61+
# env: PYTHON_ARGS=-OO
62+
#- python: 3.5
63+
# env: PANDAS=pandas NOSE_ARGS=--with-coverage DELETE_FONT_CACHE=1
64+
#- python: 3.5
65+
# env: TEST_ARGS=--pep8
66+
#- python: 3.5
67+
# env: BUILD_DOCS=true
68+
#- python: "nightly"
69+
# env: PRE=--pre
70+
#- os: osx
71+
# osx_image: xcode7.3
72+
# language: generic # https://github.com/travis-ci/travis-ci/issues/2312
73+
# env: MOCK=mock NOSE_ARGS=
74+
# cache:
75+
# # As for now travis caches only "$HOME/.cache/pip"
76+
# # https://docs.travis-ci.com/user/caching/#pip-cache
77+
# pip: false
78+
# directories:
79+
# - $HOME/Library/Caches/pip
80+
# # `cache` does not support `env`-like `global` so copy-paste from top
81+
# - $HOME/.ccache # https://github.com/travis-ci/travis-ci/issues/5853
82+
# - $HOME/.cache/matplotlib
5383
- python: 2.7
54-
env: MOCK=mock NUMPY=numpy==1.6
55-
- python: 3.4
56-
env: PYTHON_ARGS=-OO
84+
env: USE_PYTEST=true MOCK=mock NUMPY=numpy==1.6
5785
- python: 3.5
58-
env: PANDAS=pandas NOSE_ARGS=--with-coverage DELETE_FONT_CACHE=1
59-
- python: 3.5
60-
env: TEST_ARGS=--pep8
61-
- python: 3.5
62-
env: BUILD_DOCS=true
63-
- python: "nightly"
64-
env: PRE=--pre
86+
env: USE_PYTEST=true PANDAS=pandas DELETE_FONT_CACHE=1 TEST_ARGS=
6587
- os: osx
6688
osx_image: xcode7.3
67-
language: generic # https://github.com/travis-ci/travis-ci/issues/2312
68-
env: MOCK=mock NOSE_ARGS=
89+
language: generic
90+
env: USE_PYTEST=true MOCK=mock
6991
cache:
7092
# As for now travis caches only "$HOME/.cache/pip"
7193
# https://docs.travis-ci.com/user/caching/#pip-cache
@@ -77,6 +99,7 @@ matrix:
7799
- $HOME/.cache/matplotlib
78100
allow_failures:
79101
- python: "nightly"
102+
#- env: USE_PYTEST=true
80103

81104
before_install:
82105
- |
@@ -107,10 +130,15 @@ install:
107130
# Install dependencies from pypi
108131
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.2 $PANDAS pep8 cycler coveralls coverage
109132
pip install $PRE pillow sphinx!=1.3.0 $MOCK numpydoc ipython colorspacious
133+
110134
# Install nose from a build which has partial
111135
# support for python36 and suport for coverage output suppressing
112136
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose
113137
138+
# Install pytest. NOTE: nose is still needed due to `nose.tool` usage
139+
# Pin pytest-cov==2.2.1 until bug with xdist is resolved https://github.com/pytest-dev/pytest-cov/issues/124
140+
pip install $PRE pytest pytest-cov==2.2.1 pytest-timeout pytest-xdist
141+
114142
# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
115143
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
116144
# version since is it basically just a .ttf file
@@ -146,16 +174,21 @@ script:
146174
- |
147175
echo Testing import of tkagg backend
148176
MPLBACKEND="tkagg" python -c 'import matplotlib.pyplot as plt; print(plt.get_backend())'
149-
echo The following args are passed to nose $NOSE_ARGS
150177
if [[ $BUILD_DOCS == false ]]; then
151178
if [[ $DELETE_FONT_CACHE == 1 ]]; then
152179
rm -rf ~/.cache/matplotlib
153180
fi
154181
export MPL_REPO_DIR=$PWD # needed for pep8-conformance test of the examples
155-
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
156-
python tests.py $NOSE_ARGS $TEST_ARGS
182+
if [[ $USE_PYTEST == false ]]; then
183+
echo The following args are passed to nose $NOSE_ARGS
184+
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
185+
python tests.py $NOSE_ARGS $TEST_ARGS
186+
else
187+
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS tests.py $NOSE_ARGS $TEST_ARGS
188+
fi
157189
else
158-
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS tests.py $NOSE_ARGS $TEST_ARGS
190+
echo The following args are passed to pytest $PYTEST_ARGS
191+
py.test $PYTEST_ARGS $TEST_ARGS
159192
fi
160193
else
161194
cd doc
@@ -210,6 +243,6 @@ after_success:
210243
else
211244
echo "Will only deploy docs build from matplotlib master branch"
212245
fi
213-
if [[ $NOSE_ARGS="--with-coverage" ]]; then
246+
if [[ $NOSE_ARGS="--with-coverage" || $USE_PYTEST == true ]]; then
214247
coveralls
215248
fi

appveyor.yml

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,60 @@ environment:
1414
CMD_IN_ENV: "cmd /E:ON /V:ON /C obvci_appveyor_python_build_env.cmd"
1515
# Workaround for https://github.com/conda/conda-build/issues/636
1616
PYTHONIOENCODING: "UTF-8"
17+
TEST_ARGS: --no-pep8
18+
PYTEST_ARGS: -ra --timeout=300 --durations=25 #--cov-report= --cov=lib #-n %NUMBER_OF_PROCESSORS%
19+
USE_PYTEST: no
20+
PYTHONHASHSEED: 0 # Workaround for pytest-xdist flaky colletion order
21+
# https://github.com/pytest-dev/pytest/issues/920
22+
# https://github.com/pytest-dev/pytest/issues/1075
1723

1824
matrix:
19-
# for testing purpose: numpy 1.8 on py2.7, for the rest use 1.10/latest
20-
# theoretically the CONDA_INSTALL_LOCN could be only two: one for 32bit,
21-
# one for 64bit because we construct envs anyway. But using one for the
22-
# right python version is hopefully making it fast due to package caching.
25+
## for testing purpose: numpy 1.8 on py2.7, for the rest use 1.10/latest
26+
## theoretically the CONDA_INSTALL_LOCN could be only two: one for 32bit,
27+
## one for 64bit because we construct envs anyway. But using one for the
28+
## right python version is hopefully making it fast due to package caching.
29+
#- TARGET_ARCH: "x64"
30+
# CONDA_PY: "27"
31+
# CONDA_NPY: "18"
32+
# PYTHON_VERSION: "2.7"
33+
# TEST_ALL: "no"
34+
# CONDA_INSTALL_LOCN: "C:\\Miniconda-x64"
35+
#- TARGET_ARCH: "x64"
36+
# CONDA_PY: "34"
37+
# CONDA_NPY: "110"
38+
# PYTHON_VERSION: "3.4"
39+
# TEST_ALL: "no"
40+
# CONDA_INSTALL_LOCN: "C:\\Miniconda3-x64"
41+
#- TARGET_ARCH: "x64"
42+
# CONDA_PY: "35"
43+
# CONDA_NPY: "110"
44+
# PYTHON_VERSION: "3.5"
45+
# TEST_ALL: "no"
46+
# CONDA_INSTALL_LOCN: "C:\\Miniconda35-x64"
47+
#- TARGET_ARCH: "x86"
48+
# CONDA_PY: "27"
49+
# CONDA_NPY: "18"
50+
# PYTHON_VERSION: "2.7"
51+
# # this variable influence pdf/svg and most importantly the latex related tests
52+
# # which triples the runtime of the tests (7-8min vs 30min).
53+
# # pick the one which seems to make the most problems and run it last, so that
54+
# # the rest of the tests can give feedback earlier
55+
# TEST_ALL: "yes"
56+
# CONDA_INSTALL_LOCN: "C:\\Miniconda"
2357
- TARGET_ARCH: "x64"
2458
CONDA_PY: "27"
2559
CONDA_NPY: "18"
2660
PYTHON_VERSION: "2.7"
2761
TEST_ALL: "no"
2862
CONDA_INSTALL_LOCN: "C:\\Miniconda-x64"
29-
- TARGET_ARCH: "x64"
30-
CONDA_PY: "34"
31-
CONDA_NPY: "110"
32-
PYTHON_VERSION: "3.4"
33-
TEST_ALL: "no"
34-
CONDA_INSTALL_LOCN: "C:\\Miniconda3-x64"
63+
USE_PYTEST: yes
3564
- TARGET_ARCH: "x64"
3665
CONDA_PY: "35"
3766
CONDA_NPY: "110"
3867
PYTHON_VERSION: "3.5"
3968
TEST_ALL: "no"
4069
CONDA_INSTALL_LOCN: "C:\\Miniconda35-x64"
41-
- TARGET_ARCH: "x86"
42-
CONDA_PY: "27"
43-
CONDA_NPY: "18"
44-
PYTHON_VERSION: "2.7"
45-
# this variable influence pdf/svg and most importantly the latex related tests
46-
# which triples the runtime of the tests (7-8min vs 30min).
47-
# pick the one which seems to make the most problems and run it last, so that
48-
# the rest of the tests can give feedback earlier
49-
TEST_ALL: "yes"
50-
CONDA_INSTALL_LOCN: "C:\\Miniconda"
70+
USE_PYTEST: yes
5171

5272
# We always use a 64-bit machine, but can build x86 distributions
5373
# with the PYTHON_ARCH variable (which is used by CMD_IN_ENV).
@@ -58,7 +78,7 @@ platform:
5878
build: false
5979

6080
init:
61-
- cmd: "ECHO %PYTHON_VERSION% %CONDA_INSTALL_LOCN%"
81+
- cmd: "ECHO %PYTHON_VERSION% PYTEST=%USE_PYTEST% %CONDA_INSTALL_LOCN%"
6282

6383
install:
6484
- cmd: set PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\scripts;%PATH%;
@@ -82,10 +102,14 @@ install:
82102
# same things as the requirements in ci/conda_recipe/meta.yaml
83103
# if conda-forge gets a new pyqt, it might be nice to install it as well to have more backends
84104
# https://github.com/conda-forge/conda-forge.github.io/issues/157#issuecomment-223536381
85-
- cmd: conda create -q -n test-environment python=%PYTHON_VERSION% pip setuptools numpy python-dateutil freetype=2.6 msinttypes "tk=8.5" pyparsing pytz tornado "libpng>=1.6.21,<1.7" "zlib=1.2" "cycler>=0.10" nose mock
105+
- conda create -q -n test-environment python=%PYTHON_VERSION%
106+
pip setuptools numpy python-dateutil freetype=2.6 msinttypes "tk=8.5"
107+
pyparsing pytz tornado "libpng>=1.6.21,<1.7" "zlib=1.2" "cycler>=0.10"
108+
nose mock sphinx
86109
- activate test-environment
87110
- cmd: echo %PYTHON_VERSION% %TARGET_ARCH%
88111
- cmd: IF %PYTHON_VERSION% == 2.7 conda install -q functools32
112+
- if x%USE_PYTEST% == xyes conda install -q pytest pytest-cov pytest-timeout #pytest-xdist
89113

90114
# Let the install prefer the static builds of the libs
91115
- set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
@@ -124,7 +148,9 @@ test_script:
124148
# Test import of tkagg backend
125149
- python -c "import matplotlib as m; m.use('tkagg'); import matplotlib.pyplot as plt; print(plt.get_backend())"
126150
# tests
127-
- python tests.py
151+
- if x%USE_PYTEST% == xyes echo The following args are passed to pytest %PYTEST_ARGS%
152+
- if x%USE_PYTEST% == xyes py.test %PYTEST_ARGS% %TEST_ARGS%
153+
- if x%USE_PYTEST% == xno python tests.py %TEST_ARGS%
128154
# Generate a html for visual tests
129155
- python visual_tests.py
130156

0 commit comments

Comments
 (0)