Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
61 lines (45 loc) · 1.69 KB
/
Copy path__init__.py
File metadata and controls
61 lines (45 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Helper functions for testing.
"""
import locale
import logging
import sys
import warnings
import matplotlib as mpl
from matplotlib import cbook
_log = logging.getLogger(__name__)
@cbook.deprecated("3.2")
def is_called_from_pytest():
"""Whether we are in a pytest run."""
return getattr(mpl, '_called_from_pytest', False)
def _wants_nose():
wants_nose = (not getattr(mpl, '_called_from_pytest', False)
and 'nose' in sys.modules)
if wants_nose:
cbook.warn_deprecated("3.2", name="support for nose-based tests")
return wants_nose
def set_font_settings_for_testing():
mpl.rcParams['font.family'] = 'DejaVu Sans'
mpl.rcParams['text.hinting'] = False
mpl.rcParams['text.hinting_factor'] = 8
def set_reproducibility_for_testing():
mpl.rcParams['svg.hashsalt'] = 'matplotlib'
def setup():
# The baseline images are created in this locale, so we should use
# it during all of the tests.
try:
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
except locale.Error:
try:
locale.setlocale(locale.LC_ALL, 'English_United States.1252')
except locale.Error:
_log.warning(
"Could not set locale to English/United States. "
"Some date-related tests may fail.")
mpl.use('Agg', force=True, warn=False) # use Agg backend for these tests
with cbook._suppress_matplotlib_deprecation_warning():
mpl.rcdefaults() # Start with all defaults
# These settings *must* be hardcoded for running the comparison tests and
# are not necessarily the default values as specified in rcsetup.py.
set_font_settings_for_testing()
set_reproducibility_for_testing()