From e988c0e5e8f4f1d458a9fa0b8b314f40c991012d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 21 Jan 2017 23:01:19 -0500 Subject: [PATCH] Convert sphinxext tests to pytest. --- lib/matplotlib/__init__.py | 1 - .../sphinxext/tests/test_tinypages.py | 28 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 088301c7605f..768a460cd351 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1519,7 +1519,6 @@ def _jupyter_nbextension_paths(): 'matplotlib.tests.test_widgets', 'matplotlib.tests.test_cycles', 'matplotlib.tests.test_preprocess_data', - 'matplotlib.sphinxext.tests.test_tinypages', 'mpl_toolkits.tests.test_mplot3d', 'mpl_toolkits.tests.test_axes_grid1', 'mpl_toolkits.tests.test_axes_grid', diff --git a/lib/matplotlib/sphinxext/tests/test_tinypages.py b/lib/matplotlib/sphinxext/tests/test_tinypages.py index 3ad76d248b45..ca825f73b008 100644 --- a/lib/matplotlib/sphinxext/tests/test_tinypages.py +++ b/lib/matplotlib/sphinxext/tests/test_tinypages.py @@ -7,8 +7,8 @@ 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') @@ -19,7 +19,7 @@ def setup_module(): try: ret = call(['sphinx-build', '--help'], stdout=PIPE, stderr=PIPE) except OSError: - raise SkipTest('Need sphinx-build on path for these tests') + pytest.skip('Need sphinx-build on path for these tests') if ret != 0: raise RuntimeError('sphinx-build does not return 0') @@ -60,29 +60,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'), 'rb') as fobj: html_contents = fobj.read() - assert_true(b'# Only a comment' in html_contents) + assert b'# 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(b'This is the caption for plot 15.' in html_contents) + assert b'This is the caption for plot 15.' in html_contents