8000 Use sys.platform over os.name · QuLogic/matplotlib@5c3d6b0 · GitHub
[go: up one dir, main page]

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 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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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)
0