prefer sys.platform over os.name when checking for windows OS

This commit is contained in:
marsha 2023-03-03 20:16:09 -06:00
parent 2822de9aa6
commit 5ce4a549d3
8 changed files with 13 additions and 10 deletions

View file

@ -36,10 +36,10 @@ def test_read_pyvenv_cfg_non_utf8(tmpdir):
def test_norm_version_expanduser():
home = os.path.expanduser('~')
if os.name == 'nt': # pragma: nt cover
if sys.platform == 'win32': # pragma: win32 cover
path = r'~\python343'
expected_path = fr'{home}\python343'
else: # pragma: nt no cover
else: # pragma: win32 no cover
path = '~/.pyenv/versions/3.4.3/bin/python'
expected_path = f'{home}/.pyenv/versions/3.4.3/bin/python'
result = python.norm_version(path)

View file

@ -94,7 +94,7 @@ def test_normexe_does_not_exist_sep():
assert excinfo.value.args == ('Executable `./i-dont-exist-lol` not found',)
@pytest.mark.xfail(os.name == 'nt', reason='posix only')
@pytest.mark.xfail(sys.platform == 'win32', reason='posix only')
def test_normexe_not_executable(tmpdir): # pragma: win32 no cover
tmpdir.join('exe').ensure()
with tmpdir.as_cwd(), pytest.raises(OSError) as excinfo:

View file

@ -2,6 +2,7 @@ from __future__ import annotations
import os.path
import shutil
import sys
from typing import Any
from unittest import mock
@ -198,7 +199,7 @@ def test_intermixed_stdout_stderr(tempdir_factory, store):
)
@pytest.mark.xfail(os.name == 'nt', reason='ptys are posix-only')
@pytest.mark.xfail(sys.platform == 'win32', reason='ptys are posix-only')
def test_output_isatty(tempdir_factory, store):
_test_hook_repo(
tempdir_factory, store, 'stdout_stderr_repo',

View file

@ -187,7 +187,7 @@ def test_xargs_propagate_kwargs_to_cmd():
assert b'Pre commit is awesome' in stdout
@pytest.mark.xfail(os.name == 'nt', reason='posix only')
@pytest.mark.xfail(sys.platform == 'win32', reason='posix only')
def test_xargs_color_true_makes_tty():
retcode, out = xargs.xargs(
(sys.executable, '-c', 'import sys; print(sys.stdout.isatty())'),