diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index c00d05de0723..b2177e5087bc 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -1086,7 +1086,7 @@ def find_tex_file(filename): if lk: path = lk.search(filename) else: - if os.name == 'nt': + if sys.platform == 'win32': # On Windows only, kpathsea can use utf-8 for cmd args and output. # The `command_line_encoding` environment variable is set to force # it to always use utf-8 encoding. See Matplotlib issue #11848. diff --git a/lib/matplotlib/tests/test_animation.py b/lib/matplotlib/tests/test_animation.py index 750b9b32dd24..a4de96d77b62 100644 --- a/lib/matplotlib/tests/test_animation.py +++ b/lib/matplotlib/tests/test_animation.py @@ -2,6 +2,7 @@ from pathlib import Path import platform import re +import shutil import subprocess import sys import weakref @@ -318,7 +319,7 @@ def test_cleanup_temporaries(method_name, tmpdir, anim): assert list(Path(str(tmpdir)).iterdir()) == [] -@pytest.mark.skipif(os.name != "posix", reason="requires a POSIX OS") +@pytest.mark.skipif(shutil.which("/bin/sh") is None, reason="requires a POSIX OS") def test_failing_ffmpeg(tmpdir, monkeypatch, anim): """ Test that we correctly raise a CalledProcessError when ffmpeg fails. diff --git a/lib/matplotlib/tests/test_backend_webagg.py b/lib/matplotlib/tests/test_backend_webagg.py index 992827863b01..237a279c6352 100644 --- a/lib/matplotlib/tests/test_backend_webagg.py +++ b/lib/matplotlib/tests/test_backend_webagg.py @@ -11,7 +11,7 @@ def test_webagg_fallback(backend): if backend == "nbagg": pytest.importorskip("IPython") env = dict(os.environ) - if os.name != "nt": + if sys.platform != "win32": env["DISPLAY"] = "" env["MPLBACKEND"] = backend diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index b5f4db4efde6..4e088bd3fa1b 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -473,7 +473,7 @@ def test_cross_Qt_imports(): @pytest.mark.skipif('TF_BUILD' in os.environ, reason="this test fails an azure for unknown reasons") -@pytest.mark.skipif(os.name == "nt", reason="Cannot send SIGINT on Windows.") +@pytest.mark.skipif(sys.platform == "win32", reason="Cannot send SIGINT on Windows.") def test_webagg(): pytest.importorskip("tornado") proc = subprocess.Popen( diff --git a/lib/matplotlib/tests/test_matplotlib.py b/lib/matplotlib/tests/test_matplotlib.py index f30d678a52f0..ac1c3455c3d9 100644 --- a/lib/matplotlib/tests/test_matplotlib.py +++ b/lib/matplotlib/tests/test_matplotlib.py @@ -17,9 +17,9 @@ def test_parse_to_version_info(version_str, version_tuple): assert matplotlib._parse_to_version_info(version_str) == version_tuple -@pytest.mark.skipif( - os.name == "nt", reason="chmod() doesn't work as is on Windows") -@pytest.mark.skipif(os.name != "nt" and os.geteuid() == 0, +@pytest.mark.skipif(sys.platform == "win32", + reason="chmod() doesn't work as is on Windows") +@pytest.mark.skipif(sys.platform != "win32" and os.geteuid() == 0, reason="chmod() doesn't work as root") def test_tmpconfigdir_warning(tmpdir): """Test that a warning is emitted if a temporary configdir must be used."""