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

Skip to content

Commit a4427a1

Browse files
committed
Fix running of tests without installation.
* Check for installed test data only if testing installed package. * Remove relative import out of tests. * Replace assert_str_equal with plain assert (pytest does diffing already).
1 parent 5bc91c7 commit a4427a1

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,9 +1488,6 @@ def _init_tests():
14881488
else:
14891489
faulthandler.enable()
14901490

1491-
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
1492-
raise ImportError("matplotlib test data is not installed")
1493-
14941491
# The version of FreeType to install locally for running the
14951492
# tests. This must match the value in `setupext.py`
14961493
LOCAL_FREETYPE_VERSION = '2.6.1'
@@ -1526,6 +1523,8 @@ def test(verbosity=None, coverage=False, switch_backend_warn=True,
15261523
recursionlimit=0, **kwargs):
15271524
"""run the matplotlib test suite"""
15281525
_init_tests()
1526+
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
1527+
raise ImportError("matplotlib test data is not installed")
15291528

15301529
old_backend = get_backend()
15311530
old_recursionlimit = sys.getrecursionlimit()

lib/matplotlib/tests/test_preprocess_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from .. import _preprocess_data
7+
from matplotlib import _preprocess_data
88

99

1010
# Notes on testing the plotting functions itself

lib/matplotlib/tests/test_rcparams.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import mock
1818
import matplotlib as mpl
1919
import matplotlib.pyplot as plt
20-
from matplotlib.tests import assert_str_equal
2120
import matplotlib.colors as mcolors
2221
from itertools import chain
2322
import numpy as np
@@ -93,7 +92,7 @@ def test_RcParams_class():
9392
u'font.size': 12.0,
9493
u'font.weight': u'normal'})""".lstrip()
9594

96-
assert_str_equal(expected_repr, repr(rc))
95+
assert expected_repr == repr(rc)
9796

9897
if six.PY3:
9998
expected_str = """
@@ -108,7 +107,7 @@ def test_RcParams_class():
108107
font.size: 12.0
109108
font.weight: normal""".lstrip()
110109

111-
assert_str_equal(expected_str, str(rc))
110+
assert expected_str == str(rc)
112111

113112
# test the find_all functionality
114113
assert ['font.cursive', 'font.size'] == sorted(rc.find_all('i[vz]'))

0 commit comments

Comments
 (0)