|
1 | 1 | from __future__ import (absolute_import, division, print_function, |
2 | 2 | unicode_literals) |
3 | 3 |
|
4 | | -import six |
5 | | - |
6 | | -import difflib |
7 | 4 | import os |
8 | 5 |
|
9 | | -from matplotlib import rcParams, rcdefaults, use |
10 | | - |
11 | 6 |
|
12 | 7 | _multiprocess_can_split_ = True |
13 | 8 |
|
|
20 | 15 | 'This is most likely because the test data is not installed. ' |
21 | 16 | 'You may need to install matplotlib from source to get the ' |
22 | 17 | 'test data.') |
23 | | - |
24 | | - |
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 | | - |
53 | | -def assert_str_equal(reference_str, test_str, |
54 | | - format_str=('String {str1} and {str2} do not ' |
55 | | - 'match:\n{differences}')): |
56 | | - """ |
57 | | - Assert the two strings are equal. If not, fail and print their |
58 | | - diffs using difflib. |
59 | | -
|
60 | | - """ |
61 | | - if reference_str != test_str: |
62 | | - diff = difflib.unified_diff(reference_str.splitlines(1), |
63 | | - test_str.splitlines(1), |
64 | | - 'Reference', 'Test result', |
65 | | - '', '', 0) |
66 | | - raise ValueError(format_str.format(str1=reference_str, |
67 | | - str2=test_str, |
68 | | - differences=''.join(diff))) |
0 commit comments