22
33import six
44
5+ from collections import OrderedDict
6+ import copy
7+ from itertools import chain
58import os
69import warnings
7- from collections import OrderedDict
810
911from cycler import cycler , Cycler
1012import pytest
1618import matplotlib as mpl
1719import matplotlib .pyplot as plt
1820import matplotlib .colors as mcolors
19- from itertools import chain
2021import numpy as np
2122from matplotlib .rcsetup import (validate_bool_maybe_none ,
2223 validate_stringlist ,
3132 _validate_linestyle )
3233
3334
34- mpl .rc ('text' , usetex = False )
35- mpl .rc ('lines' , linewidth = 22 )
36-
37- fname = os .path .join (os .path .dirname (__file__ ), 'test_rcparams.rc' )
35+ @pytest .fixture (autouse = True )
36+ def setup_module ():
37+ with mpl .rc_context ():
38+ mpl .rc ('text' , usetex = False )
39+ mpl .rc ('lines' , linewidth = 22 )
3840
3941
4042def test_rcparams ():
4143 usetex = mpl .rcParams ['text.usetex' ]
4244 linewidth = mpl .rcParams ['lines.linewidth' ]
45+ fname = os .path .join (os .path .dirname (__file__ ), 'test_rcparams.rc' )
4346
4447 # test context given dictionary
4548 with mpl .rc_context (rc = {'text.usetex' : not usetex }):
@@ -57,9 +60,8 @@ def test_rcparams():
5760 assert mpl .rcParams ['lines.linewidth' ] == linewidth
5861
5962 # test rc_file
60- with mpl .rc_context ():
61- mpl .rc_file (fname )
62- assert mpl .rcParams ['lines.linewidth' ] == 33
63+ mpl .rc_file (fname )
64+ assert mpl .rcParams ['lines.linewidth' ] == 33
6365
6466
6567def test_RcParams_class ():
@@ -135,8 +137,7 @@ def test_Bug_2543():
135137 mpl .rcParams [key ] = _copy [key ]
136138 mpl .rcParams ['text.dvipnghack' ] = None
137139 with mpl .rc_context ():
138- from copy import deepcopy
139- _deep_copy = deepcopy (mpl .rcParams )
140+ _deep_copy = copy .deepcopy (mpl .rcParams )
140141 # real test is that this does not raise
141142 assert validate_bool_maybe_none (None ) is None
142143 assert validate_bool_maybe_none ("none" ) is None
0 commit comments