Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2047ace

Browse files
committed
Investigate test failures.
1 parent 9a80aaa commit 2047ace

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/matplotlib/tests/test_rcparams.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
import six
55

6+
from collections import OrderedDict
7+
import copy
8+
from itertools import chain
69
import os
710
import warnings
8-
from collections import OrderedDict
911

1012
from cycler import cycler, Cycler
1113
import pytest
@@ -17,7 +19,6 @@
1719
import matplotlib as mpl
1820
import matplotlib.pyplot as plt
1921
import matplotlib.colors as mcolors
20-
from itertools import chain
2122
import numpy as np
2223
from matplotlib.rcsetup import (validate_bool_maybe_none,
2324
validate_stringlist,
@@ -32,15 +33,17 @@
3233
_validate_linestyle)
3334

3435

35-
mpl.rc('text', usetex=False)
36-
mpl.rc('lines', linewidth=22)
37-
38-
fname = os.path.join(os.path.dirname(__file__), 'test_rcparams.rc')
36+
@pytest.fixture(autouse=True)
37+
def setup_module():
38+
with mpl.rc_context():
39+
mpl.rc('text', usetex=False)
40+
mpl.rc('lines', linewidth=22)
3941

4042

4143
def test_rcparams():
4244
usetex = mpl.rcParams['text.usetex']
4345
linewidth = mpl.rcParams['lines.linewidth']
46+
fname = os.path.join(os.path.dirname(__file__), 'test_rcparams.rc')
4447

4548
# test context given dictionary
4649
with mpl.rc_context(rc={'text.usetex': not usetex}):
@@ -58,9 +61,8 @@ def test_rcparams():
5861
assert mpl.rcParams['lines.linewidth'] == linewidth
5962

6063
# test rc_file
61-
with mpl.rc_context():
62-
mpl.rc_file(fname)
63-
assert mpl.rcParams['lines.linewidth'] == 33
64+
mpl.rc_file(fname)
65+
assert mpl.rcParams['lines.linewidth'] == 33
6466

6567

6668
def test_RcParams_class():
@@ -153,8 +155,7 @@ def test_Bug_2543():
153155
mpl.rcParams[key] = _copy[key]
154156
mpl.rcParams['text.dvipnghack'] = None
155157
with mpl.rc_context():
156-
from copy import deepcopy
157-
_deep_copy = deepcopy(mpl.rcParams)
158+
_deep_copy = copy.deepcopy(mpl.rcParams)
158159
# real test is that this does not raise
159160
assert validate_bool_maybe_none(None) is None
160161
assert validate_bool_maybe_none("none") is None

0 commit comments

Comments
 (0)