Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Switch testing to pytest completely#7974

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dstansby merged 14 commits intomatplotlib:masterfromQuLogic:pytest
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
6a91b9a
Use pip to install in AppVeyor too.
QuLogicJan 29, 2017
ab99e65
Rename test_only to avoid pytest collection.
QuLogicJan 31, 2017
bd91b93
Remove pytest collection filter.
QuLogicJan 31, 2017
25fdef8
Move pytest_configure into installed area.
QuLogicJan 31, 2017
c8fc318
Enable pytest-xdist on AppVeyor.
QuLogicJan 31, 2017
02d7cf8
Change stack level of Figure.gca warning.
QuLogicJan 31, 2017
30e40c6
Skip broken category test with NumPy < 1.8.0.
QuLogicJan 31, 2017
80281e9
Use pytest in matplotlib.test().
QuLogicFeb 1, 2017
c520c2c
Stop installing nose in CI.
QuLogicFeb 1, 2017
ed7d353
FIX: implement `__ne__` for `SubplotSpec`
tacaswellFeb 1, 2017
ca255dd
Normalize path case before checking for fonts.
QuLogicFeb 1, 2017
3cb2752
Fix one last old xfail call.
QuLogicFeb 1, 2017
857d846
Fix tests.py when passed explicit filenames.
QuLogicFeb 3, 2017
fe20a23
Always upload coverage on Travis.
QuLogicFeb 3, 2017
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
36 changes: 16 additions & 20 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,7 +45,6 @@ env:
- NPROC=2
- INSTALL_PEP8=
- RUN_PEP8=
- NOSE_ARGS="-j $NPROC"
- PYTEST_ARGS="-ra --maxfail=1 --timeout=300 --durations=25 --cov-report= --cov=lib -n $NPROC"
- PYTHON_ARGS=
- DELETE_FONT_CACHE=
Expand All@@ -58,7 +57,7 @@ matrix:
- python: 3.4
env: PYTHON_ARGS=-OO
- python: 3.5
env: PANDAS=pandasNOSE_ARGS=--with-coverageDELETE_FONT_CACHE=1
env: PANDAS=pandas DELETE_FONT_CACHE=1
- python: 3.5
env: BUILD_DOCS=true
- python: 3.5
Expand All@@ -70,7 +69,7 @@ matrix:
- os: osx
osx_image: xcode7.3
language: generic # https://github.com/travis-ci/travis-ci/issues/2312
env: MOCK=mock NOSE_ARGS=
env: MOCK=mock
cache:
# As for now travis caches only "$HOME/.cache/pip"
# https://docs.travis-ci.com/user/caching/#pip-cache
Expand DownExpand Up@@ -117,9 +116,6 @@ install:
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS cycler coveralls coverage $MOCK
pip install $PRE -r doc-requirements.txt

# Install nose from a build which has partial
# support for python36 and suport for coverage output suppressing
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
pip install $PRE pytest 'pytest-cov>=2.3.1' pytest-timeout pytest-xdist pytest-faulthandler $INSTALL_PEP8

Expand DownExpand Up@@ -155,21 +151,20 @@ script:
if [[ $DELETE_FONT_CACHE == 1 ]]; then
rm -rf ~/.cache/matplotlib
fi
# Workaround for pytest-xdist flaky collection order
# https://github.com/pytest-dev/pytest/issues/920
# https://github.com/pytest-dev/pytest/issues/1075
export PYTHONHASHSEED=$(shuf -i 1-4294967295 -n 1)
echo PYTHONHASHSEED=$PYTHONHASHSEED

echo The following args are passed to pytest $PYTEST_ARGS $RUN_PEP8
if [[ $USE_PYTEST == false ]]; then
echo The following args are passed to nose $NOSE_ARGS $RUN_PEP8
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
python tests.py $NOSE_ARGS $RUN_PEP8
python tests.py $PYTEST_ARGS $RUN_PEP8
else
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS tests.py $NOSE_ARGS $RUN_PEP8
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS tests.py $PYTEST_ARGS $RUN_PEP8
fi
else
# Workaround for pytest-xdist flaky colletion order
# https://github.com/pytest-dev/pytest/issues/920
# https://github.com/pytest-dev/pytest/issues/1075
export PYTHONHASHSEED=$(shuf -i 1-4294967295 -n 1)
echo PYTHONHASHSEED=$PYTHONHASHSEED

echo The following args are passed to pytest $PYTEST_ARGS $RUN_PEP8
py.test $PYTEST_ARGS $RUN_PEP8
fi
else
Expand DownExpand Up@@ -201,6 +196,11 @@ after_failure:
fi

after_success:
- |
if [[ $BUILD_DOCS == false ]]; then
coveralls
bash <(curl -s https://codecov.io/bash)
fi
- |
if [[ $TRAVIS_PULL_REQUEST == false && $TRAVIS_REPO_SLUG == 'matplotlib/matplotlib' && $BUILD_DOCS == true && $TRAVIS_BRANCH == 'master' ]]; then
cd $TRAVIS_BUILD_DIR
Expand All@@ -225,7 +225,3 @@ after_success:
else
echo "Will only deploy docs build from matplotlib master branch"
fi
if [[ $NOSE_ARGS =~ "--with-coverage" || $USE_PYTEST == true ]]; then
coveralls
bash <(curl -s https://codecov.io/bash)
fi
18 changes: 9 additions & 9 deletionsappveyor.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,11 +14,11 @@ environment:
CMD_IN_ENV: "cmd /E:ON /V:ON /C obvci_appveyor_python_build_env.cmd"
# Workaround for https://github.com/conda/conda-build/issues/636
PYTHONIOENCODING: "UTF-8"
PYTEST_ARGS: -ra --timeout=300 --durations=25 #--cov-report= --cov=lib #-n %NUMBER_OF_PROCESSORS%
PYTEST_ARGS: -ra --timeout=300 --durations=25-n %NUMBER_OF_PROCESSORS%#--cov-report= --cov=lib
USE_PYTEST: no
#PYTHONHASHSEED: 0 # Workaround for pytest-xdist flakycolletion order
# # https://github.com/pytest-dev/pytest/issues/920
# # https://github.com/pytest-dev/pytest/issues/1075
PYTHONHASHSEED: 0 # Workaround for pytest-xdist flakycollection order
# https://github.com/pytest-dev/pytest/issues/920
# https://github.com/pytest-dev/pytest/issues/1075

matrix:
# for testing purpose: numpy 1.8 on py2.7, for the rest use 1.10/latest
Expand DownExpand Up@@ -91,12 +91,12 @@ install:
- 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"
nosemock sphinx
mock sphinx
- activate test-environment
- cmd: echo %PYTHON_VERSION% %TARGET_ARCH%
- cmd: IF %PYTHON_VERSION% == 2.7 conda install -q functools32
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
-if x%USE_PYTEST% == xyesconda install -q pytest "pytest-cov>=2.3.1" pytest-timeout#pytest-xdist
- conda install -q pytest "pytest-cov>=2.3.1" pytest-timeout pytest-xdist

# Let the install prefer the static builds of the libs
- set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
Expand All@@ -116,7 +116,7 @@ install:

test_script:
# Now build the thing..
- '%CMD_IN_ENV%python setup.py develop'
- '%CMD_IN_ENV%pip install --no-deps -ve .'
# these should show no z, png, or freetype dll...
- set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe"
#- cmd: '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\_png*.pyd'
Expand All@@ -135,9 +135,9 @@ test_script:
# Test import of tkagg backend
- python -c "import matplotlib as m; m.use('tkagg'); import matplotlib.pyplot as plt; print(plt.get_backend())"
# tests
-if x%USE_PYTEST% == xyesecho The following args are passed to pytest %PYTEST_ARGS%
- echo The following args are passed to pytest %PYTEST_ARGS%
- if x%USE_PYTEST% == xyes py.test %PYTEST_ARGS%
- if x%USE_PYTEST% == xno python tests.py
- if x%USE_PYTEST% == xno python tests.py %PYTEST_ARGS%
# Generate a html for visual tests
- python visual_tests.py

Expand Down
76 changes: 0 additions & 76 deletionsconftest.py
View file
Open in desktop

This file was deleted.

51 changes: 42 additions & 9 deletionslib/matplotlib/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1474,9 +1474,10 @@ def _jupyter_nbextension_paths():


default_test_modules = [
'matplotlib.tests.test_png',
'matplotlib.tests.test_units',
]
'matplotlib.tests',
'matplotlib.sphinxext.tests',
'mpl_toolkits.tests',
]


def _init_tests():
Expand DownExpand Up@@ -1510,19 +1511,51 @@ def _init_tests():
)
)

from .testing._nose import check_deps
check_deps()
try:
import pytest
try:
from unittest import mock
except ImportError:
import mock
except ImportError:
print("matplotlib.test requires pytest and mock to run.")
raise


def test(verbosity=1, coverage=False, **kwargs):
def test(verbosity=None, coverage=False, switch_backend_warn=True,
recursionlimit=0, **kwargs):
"""run the matplotlib test suite"""
_init_tests()

from .testing._nose import test as nose_test
return nose_test(verbosity, coverage, **kwargs)
old_backend = get_backend()
old_recursionlimit = sys.getrecursionlimit()
try:
use('agg')
if recursionlimit:
sys.setrecursionlimit(recursionlimit)
import pytest

args = kwargs.pop('argv', [])
if not any(os.path.exists(arg) for arg in args):
args += ['--pyargs'] + default_test_modules

if coverage:
args += ['--cov']

if verbosity:
args += ['-' + 'v' * verbosity]

retcode = pytest.main(args, **kwargs)
finally:
if old_backend.lower() != 'agg':
use(old_backend, warn=switch_backend_warn)
if recursionlimit:
sys.setrecursionlimit(old_recursionlimit)

return retcode


test.__test__ = False #nose: this function is not a test
test.__test__ = False #pytest: this function is not a test


def _replacer(data, key):
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/figure.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1555,7 +1555,7 @@ def gca(self, **kwargs):
else:
warnings.warn('Requested projection is different from '
'current axis projection, creating new axis '
'with requested projection.')
'with requested projection.', stacklevel=2)

# no axes found, so create one which spans the figure
return self.add_subplot(1, 1, 1, **kwargs)
Expand Down
5 changes: 4 additions & 1 deletionlib/matplotlib/font_manager.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1284,13 +1284,16 @@ def findfont(self, prop, fontext='ttf', directory=None,
cached = _lookup_cache[fontext].get(prop)
if cached is not None:
return cached
else:
directory = os.path.normcase(directory)

best_score = 1e64
best_font = None

for font in fontlist:
if (directory is not None and
os.path.commonprefix([font.fname, directory]) != directory):
os.path.commonprefix([os.path.normcase(font.fname),
directory]) != directory):
continue
# Matching family should have highest priority, so it is multiplied
# by 10.0
Expand Down
5 changes: 4 additions & 1 deletionlib/matplotlib/gridspec.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -453,7 +453,6 @@ def get_position(self, fig, return_all=False):
else:
return figbox


def get_topmost_subplotspec(self):
'get the topmost SubplotSpec instance associated with the subplot'
gridspec = self.get_gridspec()
Expand All@@ -473,6 +472,10 @@ def __eq__(self, other):
self.num1 == other.num1,
self.num2 == other.num2))

if six.PY2:
def __ne__(self, other):
return not self == other

def __hash__(self):
return (hash(self._gridspec) ^
hash(self.num1) ^
Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/sphinxext/tests/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

from matplotlib.tests.conftest import mpl_test_settings
from matplotlib.tests.conftest import (mpl_test_settings,
pytest_configure, pytest_unconfigure)
10 changes: 10 additions & 0 deletionslib/matplotlib/tests/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,16 @@
import matplotlib


def pytest_configure(config):
matplotlib.use('agg')
matplotlib._called_from_pytest = True
matplotlib._init_tests()


def pytest_unconfigure(config):
matplotlib._called_from_pytest = False


@pytest.fixture(autouse=True)
def mpl_test_settings(request):
from matplotlib.testing.decorators import _do_cleanup
Expand Down
5 changes: 2 additions & 3 deletionslib/matplotlib/tests/test_backend_pgf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,9 +99,8 @@ def test_xelatex():
def test_pdflatex():
import os
if os.environ.get('APPVEYOR', False):
from matplotlib.testing import xfail
xfail("pdflatex test does not work on appveyor due "
"to missing latex fonts")
pytest.xfail("pdflatex test does not work on appveyor due to missing "
"LaTeX fonts")

rc_pdflatex = {'font.family': 'serif',
'pgf.rcfonts': False,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp