Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3909c5b

Browse filesBrowse files
committed
Merge pull request #5492 from mdboom/decorators-without-test-data
image comparison decorator shouldn't require matplotlib.tests
2 parents 98a5464 + 149ee34 commit 3909c5b
Copy full SHA for 3909c5b

File tree

Expand file treeCollapse file tree

3 files changed

+39
-39
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+39
-39
lines changed

‎lib/matplotlib/testing/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/__init__.py
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from contextlib import contextmanager
66

77
from matplotlib.cbook import is_string_like, iterable
8+
from matplotlib import rcParams, rcdefaults, use
89

910

1011
def _is_list_like(obj):
@@ -70,3 +71,37 @@ def assert_produces_warning(expected_warning=Warning, filter_level="always",
7071
% expected_warning.__name__)
7172
assert not extra_warnings, ("Caused unexpected warning(s): %r."
7273
% extra_warnings)
74+
75+
76+
def setup():
77+
# The baseline images are created in this locale, so we should use
78+
# it during all of the tests.
79+
import locale
80+
import warnings
81+
from matplotlib.backends import backend_agg, backend_pdf, backend_svg
82+
83+
try:
84+
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
85+
except locale.Error:
86+
try:
87+
locale.setlocale(locale.LC_ALL, str('English_United States.1252'))
88+
except locale.Error:
89+
warnings.warn(
90+
"Could not set locale to English/United States. "
91+
"Some date-related tests may fail")
92+
93+
use('Agg', warn=False) # use Agg backend for these tests
94+
95+
# These settings *must* be hardcoded for running the comparison
96+
# tests and are not necessarily the default values as specified in
97+
# rcsetup.py
98+
rcdefaults() # Start with all defaults
99+
rcParams['font.family'] = 'Bitstream Vera Sans'
100+
rcParams['text.hinting'] = False
101+
rcParams['text.hinting_factor'] = 8
102+
103+
# Clear the font caches. Otherwise, the hinting mode can travel
104+
# from one test to another.
105+
backend_agg.RendererAgg._fontd.clear()
106+
backend_pdf.RendererPdf.truetype_font_cache.clear()
107+
backend_svg.RendererSVG.fontd.clear()

‎lib/matplotlib/testing/decorators.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/decorators.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import matplotlib as mpl
1818
import matplotlib.style
19-
import matplotlib.tests
2019
import matplotlib.units
20+
import matplotlib.testing
2121
from matplotlib import cbook
2222
from matplotlib import ticker
2323
from matplotlib import pyplot as plt
@@ -84,7 +84,7 @@ class CleanupTest(object):
8484
def setup_class(cls):
8585
cls.original_units_registry = matplotlib.units.registry.copy()
8686
cls.original_settings = mpl.rcParams.copy()
87-
matplotlib.tests.setup()
87+
matplotlib.testing.setup()
8888

8989
@classmethod
9090
def teardown_class(cls):
@@ -371,7 +371,7 @@ def switch_backend_decorator(func):
371371
def backend_switcher(*args, **kwargs):
372372
try:
373373
prev_backend = mpl.get_backend()
374-
matplotlib.tests.setup()
374+
matplotlib.testing.setup()
375375
plt.switch_backend(backend)
376376
result = func(*args, **kwargs)
377377
finally:

‎lib/matplotlib/tests/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/__init__.py
+1-36Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import difflib
77
import os
88

9-
from matplotlib import rcParams, rcdefaults, use
10-
9+
from matplotlib.testing import setup
1110

1211
_multiprocess_can_split_ = True
1312

@@ -22,40 +21,6 @@
2221
'test data.')
2322

2423

25-
def setup():
26-
# The baseline images are created in this locale, so we should use
27-
# it during all of the tests.
28-
import locale
29-
import warnings
30-
from matplotlib.backends import backend_agg, backend_pdf, backend_svg
31-
32-
try:
33-
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
34-
except locale.Error:
35-
try:
36-
locale.setlocale(locale.LC_ALL, str('English_United States.1252'))
37-
except locale.Error:
38-
warnings.warn(
39-
"Could not set locale to English/United States. "
40-
"Some date-related tests may fail")
41-
42-
use('Agg', warn=False) # use Agg backend for these tests
43-
44-
# These settings *must* be hardcoded for running the comparison
45-
# tests and are not necessarily the default values as specified in
46-
# rcsetup.py
47-
rcdefaults() # Start with all defaults
48-
rcParams['font.family'] = 'Bitstream Vera Sans'
49-
rcParams['text.hinting'] = False
50-
rcParams['text.hinting_factor'] = 8
51-
52-
# Clear the font caches. Otherwise, the hinting mode can travel
53-
# from one test to another.
54-
backend_agg.RendererAgg._fontd.clear()
55-
backend_pdf.RendererPdf.truetype_font_cache.clear()
56-
backend_svg.RendererSVG.fontd.clear()
57-
58-
5924
def assert_str_equal(reference_str, test_str,
6025
format_str=('String {str1} and {str2} do not '
6126
'match:\n{differences}')):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.