Skip to content

Pytest documentation + build tweaks #8026

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

Merged
merged 14 commits into from
Feb 20, 2017
Merged
Prev Previous commit
Next Next commit
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).
  • Loading branch information
QuLogic committed Feb 16, 2017
commit a4427a1cf03194f8ad9c6794594e80513a85e58e
5 changes: 2 additions & 3 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,9 +1488,6 @@ def _init_tests():
else:
faulthandler.enable()

if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
raise ImportError("matplotlib test data is not installed")

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

old_backend = get_backend()
old_recursionlimit = sys.getrecursionlimit()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_preprocess_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from .. import _preprocess_data
from matplotlib import _preprocess_data


# Notes on testing the plotting functions itself
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import mock
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.tests import assert_str_equal
import matplotlib.colors as mcolors
from itertools import chain
import numpy as np
Expand Down Expand Up @@ -93,7 +92,7 @@ def test_RcParams_class():
u'font.size': 12.0,
u'font.weight': u'normal'})""".lstrip()

assert_str_equal(expected_repr, repr(rc))
assert expected_repr == repr(rc)

if six.PY3:
expected_str = """
Expand All @@ -108,7 +107,7 @@ def test_RcParams_class():
font.size: 12.0
font.weight: normal""".lstrip()

assert_str_equal(expected_str, str(rc))
assert expected_str == str(rc)

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