Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f95fefc

Browse filesBrowse files
authored
Merge pull request #14366 from anntzer/test_rcparams
TST: Move test_rcparams test files inline into test_rcparams.py.
2 parents fd9c59d + 4a1d10e commit f95fefc
Copy full SHA for f95fefc

File tree

Expand file treeCollapse file tree

5 files changed

+12
-15
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+12
-15
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ def is_url(filename):
850850

851851
@contextlib.contextmanager
852852
def _open_file_or_url(fname):
853-
if is_url(fname):
853+
if not isinstance(fname, Path) and is_url(fname):
854854
import urllib.request
855855
with urllib.request.urlopen(fname) as f:
856856
yield (line.decode('utf-8') for line in f)

‎lib/matplotlib/tests/test_rcparams.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_rcparams.py
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,33 @@
2828
_validate_linestyle)
2929

3030

31-
def test_rcparams():
31+
def test_rcparams(tmpdir):
3232
mpl.rc('text', usetex=False)
3333
mpl.rc('lines', linewidth=22)
3434

3535
usetex = mpl.rcParams['text.usetex']
3636
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')
3840

3941
# test context given dictionary
4042
with mpl.rc_context(rc={'text.usetex': not usetex}):
4143
assert mpl.rcParams['text.usetex'] == (not usetex)
4244
assert mpl.rcParams['text.usetex'] == usetex
4345

4446
# test context given filename (mpl.rc sets linewidth to 33)
45-
with mpl.rc_context(fname=fname):
47+
with mpl.rc_context(fname=rcpath):
4648
assert mpl.rcParams['lines.linewidth'] == 33
4749
assert mpl.rcParams['lines.linewidth'] == linewidth
4850

4951
# 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}):
5153
assert mpl.rcParams['lines.linewidth'] == 44
5254
assert mpl.rcParams['lines.linewidth'] == linewidth
5355

5456
# test rc_file
55-
mpl.rc_file(fname)
57+
mpl.rc_file(rcpath)
5658
assert mpl.rcParams['lines.linewidth'] == 33
5759

5860

@@ -177,11 +179,11 @@ def test_mec_rcparams():
177179
assert ln.get_markeredgecolor() == 'r'
178180

179181

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')
183185
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)
185187
assert rc.get('timezone') == 'UTC'
186188

187189

‎lib/matplotlib/tests/test_rcparams.rc

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_rcparams.rc
-3Lines changed: 0 additions & 3 deletions
This file was deleted.
-56 Bytes
Binary file not shown.

‎setupext.py

Copy file name to clipboardExpand all lines: setupext.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ def get_package_data(self):
431431
*_pkg_data_helper('matplotlib', 'tests/tinypages'),
432432
'tests/cmr10.pfb',
433433
'tests/mpltest.ttf',
434-
'tests/test_rcparams.rc',
435-
'tests/test_utf32_be_rcparams.rc',
436434
],
437435
'mpl_toolkits': [
438436
*_pkg_data_helper('mpl_toolkits', 'tests/baseline_images'),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.