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

Skip to content

Commit 45cba0f

Browse files
committed
Add test_rcparams.py to test rc_file and rc_context.
1 parent 0f81dff commit 45cba0f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/matplotlib/tests/mpl.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lines.linewidth: 33

lib/matplotlib/tests/test_rcparams.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
3+
import matplotlib as mpl
4+
mpl.rc('text', usetex=False)
5+
mpl.rc('lines', linewidth=22)
6+
7+
fname = os.path.abspath(os.path.dirname(__file__)) + os.sep + 'mpl.rc'
8+
9+
def test_rcparams():
10+
11+
usetex = mpl.rcParams['text.usetex']
12+
linewidth = mpl.rcParams['lines.linewidth']
13+
14+
# test context given dictionary
15+
with mpl.rc_context(rc={'text.usetex': not usetex}):
16+
assert mpl.rcParams['text.usetex'] == (not usetex)
17+
assert mpl.rcParams['text.usetex'] == usetex
18+
19+
# test context given filename (mpl.rc sets linewdith to 33)
20+
with mpl.rc_context(fname=fname):
21+
assert mpl.rcParams['lines.linewidth'] == 33
22+
assert mpl.rcParams['lines.linewidth'] == linewidth
23+
24+
# test context given filename and dictionary
25+
with mpl.rc_context(fname=fname, rc={'lines.linewidth': 44}):
26+
assert mpl.rcParams['lines.linewidth'] == 44
27+
assert mpl.rcParams['lines.linewidth'] == linewidth
28+
29+
# test rc_file
30+
mpl.rc_file(fname)
31+
assert mpl.rcParams['lines.linewidth'] == 33
32+
33+
34+
if __name__ == '__main__':
35+
test_rcparams()

0 commit comments

Comments
 (0)