11from collections import OrderedDict
2+ import copy
3+ from itertools import chain
4+ import locale
25import os
36from unittest import mock
47import warnings
912import matplotlib as mpl
1013import matplotlib .pyplot as plt
1114import matplotlib .colors as mcolors
12- from itertools import chain
1315import numpy as np
1416from matplotlib .rcsetup import (validate_bool_maybe_none ,
1517 validate_stringlist ,
2527 _validate_linestyle )
2628
2729
28- mpl .rc ('text' , usetex = False )
29- mpl .rc ('lines' , linewidth = 22 )
30-
31- fname = os .path .join (os .path .dirname (__file__ ), 'test_rcparams.rc' )
32-
33-
3430def test_rcparams ():
31+ mpl .rc ('text' , usetex = False )
32+ mpl .rc ('lines' , linewidth = 22 )
33+
3534 usetex = mpl .rcParams ['text.usetex' ]
3635 linewidth = mpl .rcParams ['lines.linewidth' ]
36+ fname = os .path .join (os .path .dirname (__file__ ), 'test_rcparams.rc' )
3737
3838 # test context given dictionary
3939 with mpl .rc_context (rc = {'text.usetex' : not usetex }):
@@ -51,11 +51,8 @@ def test_rcparams():
5151 assert mpl .rcParams ['lines.linewidth' ] == linewidth
5252
5353 # test rc_file
54- try :
55- mpl .rc_file (fname )
56- assert mpl .rcParams ['lines.linewidth' ] == 33
57- finally :
58- mpl .rcParams ['lines.linewidth' ] = linewidth
54+ mpl .rc_file (fname )
55+ assert mpl .rcParams ['lines.linewidth' ] == 33
5956
6057
6158def test_RcParams_class ():
@@ -131,8 +128,7 @@ def test_Bug_2543():
131128 mpl .rcParams [key ] = _copy [key ]
132129 mpl .rcParams ['text.dvipnghack' ] = None
133130 with mpl .rc_context ():
134- from copy import deepcopy
135- _deep_copy = deepcopy (mpl .rcParams )
131+ _deep_copy = copy .deepcopy (mpl .rcParams )
136132 # real test is that this does not raise
137133 assert validate_bool_maybe_none (None ) is None
138134 assert validate_bool_maybe_none ("none" ) is None
@@ -194,7 +190,6 @@ def test_mec_rcparams():
194190def test_Issue_1713 ():
195191 utf32_be = os .path .join (os .path .dirname (__file__ ),
196192 'test_utf32_be_rcparams.rc' )
197- import locale
198193 with mock .patch ('locale.getpreferredencoding' , return_value = 'UTF-32-BE' ):
199194 rc = mpl .rc_params_from_file (utf32_be , True , False )
200195 assert rc .get ('timezone' ) == 'UTC'
0 commit comments