Skip to content

Commit 5c3d6b0

Browse files
committed
Use sys.platform over os.name
mypy does not recognize the latter [1], and there is a typing failure on Windows because of `os.geteuid`. [1] python/mypy#13002
1 parent 835220b commit 5c3d6b0

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

lib/matplotlib/dviread.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ def find_tex_file(filename):
10861086
if lk:
10871087
path = lk.search(filename)
10881088
else:
1089-
if os.name == 'nt':
1089+
if sys.platform == 'win32':
10901090
# On Windows only, kpathsea can use utf-8 for cmd args and output.
10911091
# The `command_line_encoding` environment variable is set to force
10921092
# it to always use utf-8 encoding. See Matplotlib issue #11848.

lib/matplotlib/tests/test_animation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33
import platform
44
import re
5+
import shutil
56
import subprocess
67
import sys
78
import weakref
@@ -318,7 +319,7 @@ def test_cleanup_temporaries(method_name, tmpdir, anim):
318319
assert list(Path(str(tmpdir)).iterdir()) == []
319320

320321

321-
@pytest.mark.skipif(os.name != "posix", reason="requires a POSIX OS")
322+
@pytest.mark.skipif(shutil.which("/bin/sh") is None, reason="requires a POSIX OS")
322323
def test_failing_ffmpeg(tmpdir, monkeypatch, anim):
323324
"""
324325
Test that we correctly raise a CalledProcessError when ffmpeg fails.

lib/matplotlib/tests/test_backend_webagg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_webagg_fallback(backend):
1111
if backend == "nbagg":
1212
pytest.importorskip("IPython")
1313
env = dict(os.environ)
14-
if os.name != "nt":
14+
if sys.platform != "win32":
1515
env["DISPLAY"] = ""
1616

1717
env["MPLBACKEND"] = backend

lib/matplotlib/tests/test_backends_interactive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def test_cross_Qt_imports():
473473

474474
@pytest.mark.skipif('TF_BUILD' in os.environ,
475475
reason="this test fails an azure for unknown reasons")
476-
@pytest.mark.skipif(os.name == "nt", reason="Cannot send SIGINT on Windows.")
476+
@pytest.mark.skipif(sys.platform == "win32", reason="Cannot send SIGINT on Windows.")
477477
def test_webagg():
478478
pytest.importorskip("tornado")
479479
proc = subprocess.Popen(

lib/matplotlib/tests/test_matplotlib.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def test_parse_to_version_info(version_str, version_tuple):
1717
assert matplotlib._parse_to_version_info(version_str) == version_tuple
1818

1919

20-
@pytest.mark.skipif(
21-
os.name == "nt", reason="chmod() doesn't work as is on Windows")
22-
@pytest.mark.skipif(os.name != "nt" and os.geteuid() == 0,
20+
@pytest.mark.skipif(sys.platform == "win32",
21+
reason="chmod() doesn't work as is on Windows")
22+
@pytest.mark.skipif(sys.platform != "win32" and os.geteuid() == 0,
2323
reason="chmod() doesn't work as root")
2424
def test_tmpconfigdir_warning(tmpdir):
2525
"""Test that a warning is emitted if a temporary configdir must be used."""

0 commit comments

Comments
 (0)