From 01d56a66fd8f0e9bda4c5065213b2b519d2b0c17 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 12 Mar 2017 23:50:03 -0700 Subject: [PATCH] Fix testing with tests.py on Py3.6. Invoking `tests.py` used to fail on Py3.6 due to the use of deprecated invalid escapes both in the codebase and in third-party code (dateutil). Fix the codebase, skip the checks on dateutil. It is strange (and should be worth investigating...) that the CI did not fail before, as it also uses `tests.py` on Py3.6... --- lib/matplotlib/quiver.py | 2 +- lib/matplotlib/style/core.py | 2 +- lib/matplotlib/tests/test_dates.py | 6 ------ lib/matplotlib/tests/test_text.py | 2 +- tests.py | 7 ++++--- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index 283196200120..b11e9d5fa114 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -87,7 +87,7 @@ 'dots' or 'inches': pixels or inches, based on the figure dpi - 'x', 'y', or 'xy': respectively *X*, *Y*, or :math:`\sqrt{X^2 + Y^2}` + 'x', 'y', or 'xy': respectively *X*, *Y*, or :math:`\\sqrt{X^2 + Y^2}` in data units The arrows scale differently depending on the units. For diff --git a/lib/matplotlib/style/core.py b/lib/matplotlib/style/core.py index ef0d73b7bbf3..6d8b95cdc31a 100644 --- a/lib/matplotlib/style/core.py +++ b/lib/matplotlib/style/core.py @@ -32,7 +32,7 @@ # Users may want multiple library paths, so store a list of paths. USER_LIBRARY_PATHS = [os.path.join(mpl._get_configdir(), 'stylelib')] STYLE_EXTENSION = 'mplstyle' -STYLE_FILE_PATTERN = re.compile('([\S]+).%s$' % STYLE_EXTENSION) +STYLE_FILE_PATTERN = re.compile(r'([\S]+).%s$' % STYLE_EXTENSION) # A list of rcParams that should not be applied from styles diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index 0e68b4ea8190..64447e566232 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -94,12 +94,6 @@ def test_too_many_date_ticks(): # setting equal datetimes triggers and expander call in # transforms.nonsingular which results in too many ticks in the # DayLocator. This should trigger a Locator.MAXTICKS RuntimeError - warnings.filterwarnings( - 'ignore', - 'Attempting to set identical left==right results\\nin singular ' - 'transformations; automatically expanding.\\nleft=\d*\.\d*, ' - 'right=\d*\.\d*', - UserWarning, module='matplotlib.axes') t0 = datetime.datetime(2000, 1, 20) tf = datetime.datetime(2000, 1, 20) fig = plt.figure() diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index b2d906199a3f..ada43bfd7b60 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -30,7 +30,7 @@ def find_matplotlib_font(**kw): from matplotlib.font_manager import FontProperties, findfont warnings.filterwarnings( 'ignore', - "findfont: Font family \[u?'Foo'\] not found. Falling back to .", + r"findfont: Font family \[u?'Foo'\] not found. Falling back to .", UserWarning, module='matplotlib.font_manager') diff --git a/tests.py b/tests.py index 6a86ae84d4fd..88d3e2195343 100755 --- a/tests.py +++ b/tests.py @@ -14,15 +14,16 @@ if __name__ == '__main__': + import dateutil.parser try: import setuptools except ImportError: pass # The warnings need to be before any of matplotlib imports, but after - # setuptools (if present) which has syntax error with the warnings enabled. - # Filtering by module does not work as this will be raised by Python itself - # so `module=matplotlib.*` is out of questions. + # dateutil.parser and setuptools (if present) which has syntax error with + # the warnings enabled. Filtering by module does not work as this will be + # raised by Python itself so `module=matplotlib.*` is out of question. import warnings