|
28 | 28 | _validate_linestyle) |
29 | 29 |
|
30 | 30 |
|
31 | | -def test_rcparams(): |
| 31 | +def test_rcparams(tmpdir): |
32 | 32 | mpl.rc('text', usetex=False) |
33 | 33 | mpl.rc('lines', linewidth=22) |
34 | 34 |
|
35 | 35 | usetex = mpl.rcParams['text.usetex'] |
36 | 36 | linewidth = mpl.rcParams['lines.linewidth'] |
37 | | - fname = os.path.join(os.path.dirname(__file__), 'test_rcparams.rc') |
| 37 | + |
| 38 | + rcpath = Path(tmpdir) / 'test_rcparams.rc' |
| 39 | + rcpath.write_text('lines.linewidth: 33') |
38 | 40 |
|
39 | 41 | # test context given dictionary |
40 | 42 | with mpl.rc_context(rc={'text.usetex': not usetex}): |
41 | 43 | assert mpl.rcParams['text.usetex'] == (not usetex) |
42 | 44 | assert mpl.rcParams['text.usetex'] == usetex |
43 | 45 |
|
44 | 46 | # test context given filename (mpl.rc sets linewidth to 33) |
45 | | - with mpl.rc_context(fname=fname): |
| 47 | + with mpl.rc_context(fname=rcpath): |
46 | 48 | assert mpl.rcParams['lines.linewidth'] == 33 |
47 | 49 | assert mpl.rcParams['lines.linewidth'] == linewidth |
48 | 50 |
|
49 | 51 | # test context given filename and dictionary |
50 | | - with mpl.rc_context(fname=fname, rc={'lines.linewidth': 44}): |
| 52 | + with mpl.rc_context(fname=rcpath, rc={'lines.linewidth': 44}): |
51 | 53 | assert mpl.rcParams['lines.linewidth'] == 44 |
52 | 54 | assert mpl.rcParams['lines.linewidth'] == linewidth |
53 | 55 |
|
54 | 56 | # test rc_file |
55 | | - mpl.rc_file(fname) |
| 57 | + mpl.rc_file(rcpath) |
56 | 58 | assert mpl.rcParams['lines.linewidth'] == 33 |
57 | 59 |
|
58 | 60 |
|
@@ -177,11 +179,11 @@ def test_mec_rcparams(): |
177 | 179 | assert ln.get_markeredgecolor() == 'r' |
178 | 180 |
|
179 | 181 |
|
180 | | -def test_Issue_1713(): |
181 | | - utf32_be = os.path.join(os.path.dirname(__file__), |
182 | | - 'test_utf32_be_rcparams.rc') |
| 182 | +def test_Issue_1713(tmpdir): |
| 183 | + rcpath = Path(tmpdir) / 'test_rcparams.rc' |
| 184 | + rcpath.write_text('timezone: UTC', encoding='UTF-32-BE') |
183 | 185 | with mock.patch('locale.getpreferredencoding', return_value='UTF-32-BE'): |
184 | | - rc = mpl.rc_params_from_file(utf32_be, True, False) |
| 186 | + rc = mpl.rc_params_from_file(rcpath, True, False) |
185 | 187 | assert rc.get('timezone') == 'UTC' |
186 | 188 |
|
187 | 189 |
|
|
0 commit comments