Skip to content

WIP: issue #5325, convert from nose to pytest #5405

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

Closed
wants to merge 174 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
4c39e53
ENH: use pytest instead of nose.
pizzathief Oct 31, 2015
f10a36b
pytest.raises(), not pytest.raise()
pizzathief Nov 4, 2015
c17005b
pytest.raises() calls needed some massaging
pizzathief Nov 4, 2015
1a75b75
replace nose with pytest in INSTALL
pizzathief Nov 4, 2015
b123ed7
altering more assert_equal calls.
pizzathief Nov 4, 2015
5f433fb
fixing up problems with assert, and the use of messages.
pizzathief Nov 5, 2015
cfb8d71
flake8 failures
pizzathief Nov 5, 2015
89d3366
flake8 doesn't like blank lines at ends of files.
pizzathief Nov 5, 2015
887e482
flake8 fixes
pizzathief Nov 5, 2015
8f16316
fixed syntax errors
pizzathief Nov 5, 2015
b56297f
just have it on one line
pizzathief Nov 5, 2015
df4e413
fix errors highlighted in travis CI logs
pizzathief Nov 5, 2015
defa65d
fixing reported test failures, reported by pytest on travis.
pizzathief Nov 5, 2015
b8b3909
fixing pytest failures. Interesting that assert can't seem to handle
pizzathief Nov 5, 2015
5fd4351
fixing syntax failures
pizzathief Nov 5, 2015
47c968b
Force travis to install pytest, and plugins
pizzathief Nov 5, 2015
1b509c1
get travis to run py.test instead of nose.
pizzathief Nov 6, 2015
432e9e8
small pep8 fix to force travis to build
pizzathief Nov 6, 2015
60b038c
lets see if indenting a comment fixes the problem
pizzathief Nov 6, 2015
2984d44
give py.test the install location of the module, rather
pizzathief Nov 7, 2015
e27451d
forgot to remove the bad py.test call.
pizzathief Nov 7, 2015
784fdf8
force pytest-pep8 to ignore the pep8 warnings that
pizzathief Nov 7, 2015
f035db7
temporarily adding more items to be ignored by pep8,
pizzathief Nov 7, 2015
1e7b62c
trying out --pyargs as requested, also removing pep checks,
pizzathief Nov 7, 2015
56d99ed
tests.py should now act more like the old nose version did,
pizzathief Nov 8, 2015
7d38aa3
lets try the 'gdb python tests.py' method again.
pizzathief Nov 8, 2015
7bbc04a
the switches that nose needed , make pytest fail, so lets
pizzathief Nov 8, 2015
05da48a
pytest.main doesn't like --pyargs now? it used to..
pizzathief Nov 9, 2015
98b1e69
Adding in all tests to the list, including argv[1:]
pizzathief Nov 13, 2015
6853e71
seems --processes=2 and --process-timeout=300
pizzathief Nov 13, 2015
105a15d
replace assert_raises with pytest.raises
pizzathief Nov 13, 2015
5482cc7
another assert_raises to replace with pytest.raises
pizzathief Nov 13, 2015
4a8caad
replace assert_raises with pytest.raises
pizzathief Nov 13, 2015
8985c35
Fixing errors that appear before testing starts
pizzathief Nov 13, 2015
789f864
replaced a nose function for known failing tests
pizzathief Nov 13, 2015
4900796
updating basic tests that are know to fail with
pizzathief Nov 14, 2015
0633576
add the ability to only run pep8 tests. remove commented out means
pizzathief Nov 18, 2015
47ef9f0
ass civerage report as standard
pizzathief Nov 18, 2015
2a7637c
no need for the nose pep8 tests, so remove from tests.py
pizzathief Nov 18, 2015
08ae5ef
pep8 and non-pep8 tests act better now. taking out
pizzathief Nov 25, 2015
bd0c061
remove more of the nose infrastructure
pizzathief Nov 27, 2015
42e7ae1
Pass the exit code of pytest.main back to the shell.
pizzathief Dec 13, 2015
86820be
replace nose decorator with pytest code.
pizzathief Dec 13, 2015
37c67c2
whoops, deleted an 'a' from a variable while doing
pizzathief Dec 13, 2015
84359ac
fix up a bunch of pytest.raises calls.
pizzathief Dec 13, 2015
c76bef9
found 'assert_less' calls to replace
pizzathief Dec 13, 2015
2e58461
found a space and comma char that had attempted an escape of the faci…
pizzathief Dec 13, 2015
517b232
found some assert_equal statements to convert.
pizzathief Dec 13, 2015
9aee1fc
converted assert_raises calls to pytest.raises.
pizzathief Dec 13, 2015
91f3032
more assert_raises calls to replace
pizzathief Dec 13, 2015
86f7264
Thanks to QuLogic , using decorator form of pytest.raises for
pizzathief Dec 13, 2015
f7e7401
more conversions of pytest.raises to use 'with' instead.
pizzathief Dec 13, 2015
6f935ce
change nose method for calling test class methods.
pizzathief Dec 14, 2015
72ddc43
fixing pep8 failures.
pizzathief Dec 14, 2015
2d71f19
more pep8 fixes.
pizzathief Dec 14, 2015
571fbbd
another testing class that needed changes for pytest.
pizzathief Dec 14, 2015
50b0e0a
more pep8 failures to hide under the rug.
pizzathief Dec 14, 2015
4408d10
another pytest.raises to fix.
pizzathief Dec 14, 2015
4e87b72
lets try not comparing the equivilance of empty dicts, but rather
pizzathief Dec 14, 2015
6d3bb58
if commenting out the nose pep8 functions work, then they
pizzathief Dec 14, 2015
4bfbf26
pep8 fixes.
pizzathief Dec 14, 2015
1ffc9c2
fix typos found QuLogic
pizzathief Dec 14, 2015
389ebc3
removing (and moving) import code in tests.py
pizzathief Dec 15, 2015
1f1c2a6
replacing new nose calls with plain asserts
pizzathief Dec 15, 2015
01df455
exclude files from pep8 checking
pizzathief Dec 15, 2015
bb3ab51
add support for running a single test module, instead of all of them
pizzathief Dec 21, 2015
73e9383
The "_name.py" files in exclude_files might need globbing to
pizzathief Dec 28, 2015
5f3255b
pep8 failures
pizzathief Dec 28, 2015
f4826c3
pep8 was demanding that lambdas be replaced with proper functions.
pizzathief Dec 28, 2015
08ce37b
This is hopefully an acceptable solution to the problem with
pizzathief Dec 28, 2015
f705680
pep8 failures
pizzathief Dec 28, 2015
9aac515
remove assert_not_equal
pizzathief Dec 28, 2015
4a62ad9
lets try '--ignore'ing the numpy tests dir
pizzathief Dec 31, 2015
df2ebeb
Don't code at night on holidays with bad specs.
pizzathief Dec 31, 2015
1e12273
try norecursedirs to get pytest to stop looking in numpy
pizzathief Jan 1, 2016
47e0c4b
found cases of 'import nose' , and also, use of
pizzathief Jan 2, 2016
d04ab5c
needed to specify 'reason=' for xfail to work
pizzathief Jan 2, 2016
57b2f17
need to specify a 'reason=' to use pytest.maek.xfail
pizzathief Jan 2, 2016
636728f
don't need knownfailureif
pizzathief Jan 2, 2016
b0a342d
pytest xfail needs a 'reason'
pizzathief Jan 2, 2016
78587c1
fixing up small pytest issues
pizzathief Jan 2, 2016
09e559a
don't need the nose make_decorator function any more.
pizzathief Jan 4, 2016
8c3f2f1
to please the pep8 gods, we sacrifice this line break.
pizzathief Jan 4, 2016
62983b5
replace a knownfailureif call, and fix up pytest xfail calls
pizzathief Jan 4, 2016
e83807f
make_decorator seems to be described here.
pizzathief Jan 4, 2016
22ee978
resolve the oeo8 allergy to blank lines,
pizzathief Jan 4, 2016
ea7c57f
fix up xfail calls
pizzathief Jan 4, 2016
3008a22
another zfail reason fix
pizzathief Jan 4, 2016
49d2315
typo
pizzathief Jan 4, 2016
a1f31a8
don't import from nose , and don't need knownfailure
pizzathief Jan 5, 2016
e812aac
remove knownfailureif reference
pizzathief Jan 5, 2016
4fff146
An attempt to make a image_comparison decorator that doesn't fail
pizzathief Jan 8, 2016
738da3e
fix up indentation for import
pizzathief Jan 8, 2016
da60028
another fix for indentation. kinda non-dry'y
pizzathief Jan 8, 2016
726cc92
removed mentions of 'import nose'
pizzathief Jan 11, 2016
f17a2db
more nose lines to change
pizzathief Jan 11, 2016
683546e
regex assertions to convert
pizzathief Jan 11, 2016
63eae4b
replaced nose.assert_almost_equal with the numpy one, but
pizzathief Jan 11, 2016
6c46f42
basic nose replacement stuff
pizzathief Jan 11, 2016
c4a824e
fix up test failures caused through rebase
pizzathief Jan 14, 2016
ac14548
add in the ability to filter out numpy files from consideration
pizzathief Jan 15, 2016
3f45e42
fix up test_mlab.py raises and nose import lines
pizzathief Jan 17, 2016
38c29c6
fix test_apply_window_*D* function calls in test_mlab.py
pizzathief Jan 17, 2016
fc4e025
fix test_LogLocator in test_ticker.py
pizzathief Jan 17, 2016
ade1890
fix lack of pytest import in test_transforms.py
pizzathief Jan 17, 2016
1cbd24a
remove __name__ == '__main__' from many test files
pizzathief Jan 17, 2016
373fa15
PEP8 E301 in test_docstring_addition
pizzathief Jan 17, 2016
ca9828a
PEP8 E302 in test_transforms.py, test_transformed_path
pizzathief Jan 17, 2016
fa1e601
PEP8 E261 in test_mathtext.py, math_tests[]
pizzathief Jan 17, 2016
534ab6f
PEP8 E712 in test_figure.py, test_fignum_exists
pizzathief Jan 18, 2016
db2d85b
PEP8 E302 test_dviread.py around setup_PsfontsMap
pizzathief Jan 18, 2016
c4ea6d4
PEP8 E712 in test_axes.py
pizzathief Jan 18, 2016
a2291a1
PEP8 E712 in test_artist.py , test_remove
pizzathief Jan 18, 2016
65b42bd
PEP8 W293 in test_labeled_data_unpacking.py, test_docstring_addition
pizzathief Jan 18, 2016
8a22e2a
fix bad pytest raises calls in test_triangulation.py
pizzathief Jan 18, 2016
6ed71fa
fix bad pytest.raises calls in test_cbook.py test_step_fails
pizzathief Jan 18, 2016
f78c075
fix bad assert calls in test_pickle.py , test_transform
pizzathief Jan 18, 2016
1d7b37c
fix bad pytest.raises calls in test_colors.py, test_colors_no_float
pizzathief Jan 18, 2016
90bbe25
fix pytest.raises call in test_colors.py test_cmap_and_norm_from_leve…
pizzathief Jan 18, 2016
ee30e10
fix rebase omission, test_transform in test_pickle.py
pizzathief Jan 18, 2016
35520a4
fix user searh, not match in test_labeled_data_unpacking, test_docstr…
pizzathief Jan 18, 2016
b3c7dda
fix test_invalid_input_forms in test_cycles.py
pizzathief Jan 18, 2016
331428f
fix nose skiptest references, test_axes.py
pizzathief Jan 18, 2016
ea38ba6
remove nose import references, many files
pizzathief Jan 18, 2016
2cb6b8c
PEP8 E302 at test_gridspec.py
pizzathief Jan 18, 2016
accbcf2
doc convert nose docs to pytest, testing.rst
pizzathief Jan 19, 2016
a4ddff3
fix remove nose install from travis
pizzathief Jan 19, 2016
bd5828f
fix syntax error (newline) in testing.rst
pizzathief Jan 19, 2016
930c529
fix numpy pytest errors. don't put pylab in default namespace
pizzathief Jan 19, 2016
ae9715c
ENH: use pytest instead of nose.
pizzathief Oct 31, 2015
edabe74
pytest.raises(), not pytest.raise()
pizzathief Nov 4, 2015
23d6fae
pytest.raises() calls needed some massaging
pizzathief Nov 4, 2015
f27909a
fixing up problems with assert, and the use of messages.
pizzathief Nov 5, 2015
a023347
fix errors highlighted in travis CI logs
pizzathief Nov 5, 2015
dd8111b
fixing pytest failures. Interesting that assert can't seem to handle
pizzathief Nov 5, 2015
9f53f57
fixing syntax failures
pizzathief Nov 5, 2015
eefe67d
force pytest-pep8 to ignore the pep8 warnings that
pizzathief Nov 7, 2015
2661e32
the switches that nose needed , make pytest fail, so lets
pizzathief Nov 8, 2015
f404baa
another assert_raises to replace with pytest.raises
pizzathief Nov 13, 2015
53457e9
replaced a nose function for known failing tests
pizzathief Nov 13, 2015
0f9fae8
remove more of the nose infrastructure
pizzathief Nov 27, 2015
cd961cc
fix up a bunch of pytest.raises calls.
pizzathief Dec 13, 2015
de69032
converted assert_raises calls to pytest.raises.
pizzathief Dec 13, 2015
42185f8
fixing pep8 failures.
pizzathief Dec 14, 2015
cd81fbf
more pep8 failures to hide under the rug.
pizzathief Dec 14, 2015
523bb86
if commenting out the nose pep8 functions work, then they
pizzathief Dec 14, 2015
859f8d5
removing (and moving) import code in tests.py
pizzathief Dec 15, 2015
ad48b37
pep8 failures
pizzathief Dec 28, 2015
9a0b134
try norecursedirs to get pytest to stop looking in numpy
pizzathief Jan 1, 2016
23cee6a
found cases of 'import nose' , and also, use of
pizzathief Jan 2, 2016
c59a7b0
don't need the nose make_decorator function any more.
pizzathief Jan 4, 2016
43fd3e2
make_decorator seems to be described here.
pizzathief Jan 4, 2016
108522a
An attempt to make a image_comparison decorator that doesn't fail
pizzathief Jan 8, 2016
90221b9
fix up indentation for import
pizzathief Jan 8, 2016
6f74d88
another fix for indentation. kinda non-dry'y
pizzathief Jan 8, 2016
0ba7323
removed mentions of 'import nose'
pizzathief Jan 11, 2016
39612f6
fix up test failures caused through rebase
pizzathief Jan 14, 2016
336d1eb
remove __name__ == '__main__' from many test files
pizzathief Jan 17, 2016
7d9fdf6
fix test_invalid_input_forms in test_cycles.py
pizzathief Jan 18, 2016
606907b
fix nose skiptest references, test_axes.py
pizzathief Jan 18, 2016
db5f5e5
fix numpy pytest errors. don't put pylab in default namespace
pizzathief Jan 19, 2016
37418d8
PEP8 E502 at test_simplification.py, test_fft_peaks
pizzathief Jan 19, 2016
01b9215
remove @cleanup operator from test_complete. Its causing a pytest
pizzathief Jan 21, 2016
b9c0ee7
PEP8 E302 around teardown_PsfontsMap, test_dviread.py
pizzathief Jan 22, 2016
e002e48
fix lack of _func error in image_comparison_2, decorators.py
pizzathief Jan 22, 2016
25f77bc
fix assert_raises call in test_valid_linestyles, test_lines.py
pizzathief Jan 22, 2016
1996513
fix syntax error (another newline) in testing.rst, rst files
pizzathief Jan 22, 2016
07313db
doc lets remove pytest targets in rst for now
pizzathief Jan 22, 2016
280be1b
convert pytest.raises(error,f,x,y) calls to with pytest.raises
pizzathief Jan 23, 2016
a135e56
fix test_positional_parameter_names_as_function , seems getting a
pizzathief Jan 23, 2016
e52e0fc
PEP8 E201 in test_stride_windows_0D_ValueError, test_mlab.py
pizzathief Jan 23, 2016
d2f4e6b
as requested, push a simple change to test appveyor
pizzathief Feb 8, 2016
bf19dad
trying to get pytest to recognise dynamically created test
pizzathief Feb 10, 2016
f111193
make tests.py handle single modules better
pizzathief Feb 10, 2016
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
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ env:
- NUMPY=numpy
- PANDAS=
- NPROC=2
- TEST_ARGS=--no-pep8
- TEST_ARGS=
- NOSE_ARGS="--processes=$NPROC --process-timeout=300"

language: python
Expand All @@ -46,7 +46,7 @@ matrix:
- python: 3.5
env: PANDAS=pandas NOSE_ARGS=--with-coverage
- python: 3.5
env: TEST_ARGS=--pep8
env: TEST_ARGS=--pep8 -m pep8
- python: 3.5
env: BUILD_DOCS=true
- python: "nightly"
Expand Down Expand Up @@ -77,7 +77,15 @@ install:
fi
# Always install from pypi
- pip install $PRE pep8 cycler coveralls coverage
- 'pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose'
# 'pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose'
- pip install pytest

# some handy plugins for pytest, is this the right place to install them?
# https://pypi.python.org/pypi/pytest-cov for docs
- pip install pytest-cov
# https://pypi.python.org/pypi/pytest-pep8 for docs
- pip install pytest-pep8
Copy link
Member

Choose a reason for hiding this comment

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

This is the right place to install them. You could put them all on one line:

pip install pytest pytest-cov pytest-pep8



# 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
Expand Down Expand Up @@ -111,7 +119,7 @@ script:
- |
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 $NOSE_ARGS $TEST_ARGS
gdb -return-child-result -batch -ex r -ex bt --args python tests.py $TEST_ARGS
else
cd doc
python make.py html --small --warningsaserrors
Expand Down
14 changes: 7 additions & 7 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ not contain test data or example code. If you want to try the many
demos that come in the matplotlib source distribution, download the
:file:`*.tar.gz` file and look in the :file:`examples` subdirectory.
To run the test suite, copy the :file:`lib\matplotlib\tests` and
:file:`lib\mpl_toolkits\tests` directories from the source
distribution to :file:`sys.prefix\Lib\site-packages\matplotlib` and
:file:`sys.prefix\Lib\site-packages\mpl_toolkits` respectively, and
install `nose <https://pypi.python.org/pypi/nose>`_, `mock
<https://pypi.python.org/pypi/mock>`_, Pillow, MiKTeX, GhostScript,
ffmpeg, avconv, mencoder, ImageMagick, and `Inkscape
<http://inkscape.org/>`_.
:file:`lib\mpl_toolkits\tests` directories from the source distribution to
:file:`sys.prefix\Lib\site-packages\matplotlib` and
:file:`sys.prefix\Lib\site-packages\mpl_toolkits` respectively, and install
`pytest <https://pypi.python.org/pypi/pytest>`_,
`mock <https://pypi.python.org/pypi/mock>`_,
Pillow, MiKTeX, GhostScript, ffmpeg, avconv, mencoder, ImageMagick, and
`Inkscape <http://inkscape.org/>`_.



Expand Down
Empty file added conftest.py
Empty file.
24 changes: 14 additions & 10 deletions doc/devel/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
Testing
=======

Matplotlib has a testing infrastructure based on nose_, making it easy
Matplotlib has a testing infrastructure based on pytest, making it easy
to write new tests. The tests are in :mod:`matplotlib.tests`, and
customizations to the nose testing infrastructure are in
customizations to the pytest testing infrastructure are in
:mod:`matplotlib.testing`. (There is other old testing cruft around,
please ignore it while we consolidate our testing to these locations.)

.. _nose: http://nose.readthedocs.org/en/latest/
.. pytest: http://pytest.readthedocs.org/en/latest/

Requirements
------------

The following software is required to run the tests:

- nose_, version 1.0 or later
- pytest

- `mock <http://www.voidspace.org.uk/python/mock/>`_, when running python
versions < 3.3
Expand All @@ -33,6 +33,10 @@ Optionally you can install:

- `pep8 <http://pep8.readthedocs.org/en/latest>`_ to test coding standards

- `pytest-cov <https://pypi.python.org/pypi/pytest-cov>`_ for coverage stats in pytest

- `pytest-pep8 <https://pypi.python.org/pypi/pytest-pep8>`_ for pep8 conformance in pytest

Building matplotlib for image comparison tests
----------------------------------------------

Expand All @@ -52,7 +56,7 @@ matplotlib source directory::
Running the tests
-----------------

Running the tests is simple. Make sure you have nose installed and run::
Running the tests is simple. Make sure you have pytest installed and run::

python tests.py

Expand Down Expand Up @@ -112,15 +116,15 @@ Writing a simple test
Many elements of Matplotlib can be tested using standard tests. For
example, here is a test from :mod:`matplotlib.tests.test_basic`::

from nose.tools import assert_equal
import pytest

def test_simple():
"""
very simple example test
"""
assert_equal(1+1,2)
assert 1+1 == 2

Nose determines which functions are tests by searching for functions
Pytest determines which functions are tests by searching for functions
beginning with "test" in their name.

If the test has side effects that need to be cleaned up, such as
Expand Down Expand Up @@ -203,15 +207,15 @@ Known failing tests
-------------------

If you're writing a test, you may mark it as a known failing test with
the :func:`~matplotlib.testing.decorators.knownfailureif`
the :func:`~pytest.mark.xfail`
decorator. This allows the test to be added to the test suite and run
on the buildbots without causing undue alarm. For example, although
the following test will fail, it is an expected failure::

from nose.tools import assert_equal
from matplotlib.testing.decorators import knownfailureif

@knownfailureif(True)
@pytest.mark.xfail()
def test_simple_fail():
'''very simple example test that should fail'''
assert_equal(1+1,3)
Expand Down
11 changes: 6 additions & 5 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,21 +1515,22 @@ def _init_tests():
"Expect many image comparison failures below.")

try:
import nose
# import nose
try:
from unittest import mock
except:
import mock
except ImportError:
print("matplotlib.test requires nose and mock to run.")
print("matplotlib.test requires mock to run. nose is currently being removed")
raise


def _get_extra_test_plugins():
from .testing.noseclasses import KnownFailure
from nose.plugins import attrib
# from .testing.noseclasses import KnownFailure
# from nose.plugins import attrib

return [KnownFailure, attrib.Plugin]
#return [KnownFailure, attrib.Plugin]
pass


def _get_nose_env():
Expand Down
29 changes: 29 additions & 0 deletions lib/matplotlib/ignorenumpytests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
"""
So pytest is trying to load tests in numpy, and generates this error

____________________________ ERROR at setup of test ____________________________
file /home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/
numpy/testing/nosetester.py, line 249
def test(self, label='fast', verbose=1, extra_argv=None, doctests=False,
fixture 'self' not found
available fixtures: tmpdir_factory, pytestconfig, cov, cache, recwarn,
monkeypatch, record_xml_property, capfd, capsys, tmpdir

use 'py.test --fixtures [testpath]' for help on them.
/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/
numpy/testing/nosetester.py:249

this file is intended to stop that behaviour, by blocking files from
being considered for collection if "numpy" is in the path
"""

def pytest_ignore_collect(path, config):
if 'numpy' not in path.basename:
print('allowing ', path)
return True
else:
print('blocking ', path)
return False

# return 'numpy' not in path.basename:
27 changes: 13 additions & 14 deletions lib/matplotlib/sphinxext/tests/test_tinypages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

from subprocess import call, Popen, PIPE

from nose import SkipTest
from nose.tools import assert_true
import pytest

HERE = dirname(__file__)
TINY_PAGES = pjoin(HERE, 'tinypages')
Expand All @@ -19,7 +18,7 @@ def setup():
try:
ret = call(['sphinx-build', '--help'], stdout=PIPE, stderr=PIPE)
except OSError:
raise SkipTest('Need sphinx-build on path for these tests')
raise pytest.skip('Need sphinx-build on path for these tests')
if ret != 0:
raise RuntimeError('sphinx-build does not return 0')

Expand Down Expand Up @@ -62,29 +61,29 @@ def teardown_class(cls):
shutil.rmtree(cls.page_build)

def test_some_plots(self):
assert_true(isdir(self.html_dir))
assert isdir(self.html_dir)

def plot_file(num):
return pjoin(self.html_dir, 'some_plots-{0}.png'.format(num))

range_10, range_6, range_4 = [plot_file(i) for i in range(1, 4)]
# Plot 5 is range(6) plot
assert_true(file_same(range_6, plot_file(5)))
assert file_same(range_6, plot_file(5))
# Plot 7 is range(4) plot
assert_true(file_same(range_4, plot_file(7)))
assert file_same(range_4, plot_file(7))
# Plot 11 is range(10) plot
assert_true(file_same(range_10, plot_file(11)))
assert file_same(range_10, plot_file(11))
# Plot 12 uses the old range(10) figure and the new range(6) figure
assert_true(file_same(range_10, plot_file('12_00')))
assert_true(file_same(range_6, plot_file('12_01')))
assert file_same(range_10, plot_file('12_00'))
assert file_same(range_6, plot_file('12_01'))
# Plot 13 shows close-figs in action
assert_true(file_same(range_4, plot_file(13)))
assert file_same(range_4, plot_file(13))
# Plot 14 has included source
with open(pjoin(self.html_dir, 'some_plots.html'), 'rt') as fobj:
html_contents = fobj.read()
assert_true('# Only a comment' in html_contents)
assert '# Only a comment' in html_contents
# check plot defined in external file.
assert_true(file_same(range_4, pjoin(self.html_dir, 'range4.png')))
assert_true(file_same(range_6, pjoin(self.html_dir, 'range6.png')))
assert file_same(range_4, pjoin(self.html_dir, 'range4.png'))
assert file_same(range_6, pjoin(self.html_dir, 'range6.png'))
# check if figure caption made it into html file
assert_true('This is the caption for plot 15.' in html_contents)
assert 'This is the caption for plot 15.' in html_contents
Loading