deep listdir works in python3 on windows

This commit is contained in:
Anthony Sottile
2020-01-12 12:29:50 -08:00
parent 5779f93ec6
commit 5706b9149c
3 changed files with 4 additions and 30 deletions

View File

@@ -30,7 +30,7 @@ def _envdir(prefix: Prefix, version: str) -> str:
return prefix.path(directory)
def get_env_patch(venv: str) -> PatchesT: # pragma: windows no cover
def get_env_patch(venv: str) -> PatchesT:
if sys.platform == 'cygwin': # pragma: no cover
_, win_venv, _ = cmd_output('cygpath', '-w', venv)
install_prefix = fr'{win_venv.strip()}\bin'
@@ -54,14 +54,14 @@ def get_env_patch(venv: str) -> PatchesT: # pragma: windows no cover
def in_env(
prefix: Prefix,
language_version: str,
) -> Generator[None, None, None]: # pragma: windows no cover
) -> Generator[None, None, None]:
with envcontext(get_env_patch(_envdir(prefix, language_version))):
yield
def install_environment(
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
) -> None: # pragma: windows no cover
) -> None:
additional_dependencies = tuple(additional_dependencies)
assert prefix.exists('package.json')
envdir = _envdir(prefix, version)
@@ -91,6 +91,6 @@ def run_hook(
hook: 'Hook',
file_args: Sequence[str],
color: bool,
) -> Tuple[int, bytes]: # pragma: windows no cover
) -> Tuple[int, bytes]:
with in_env(hook.prefix, hook.language_version):
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)

View File

@@ -1,7 +1,6 @@
import contextlib
import os.path
import subprocess
import sys
import pytest
@@ -46,27 +45,6 @@ xfailif_windows_no_ruby = pytest.mark.xfail(
xfailif_windows = pytest.mark.xfail(os.name == 'nt', reason='windows')
def broken_deep_listdir(): # pragma: no cover (platform specific)
if sys.platform != 'win32':
return False
try:
os.listdir('\\\\?\\' + os.path.abspath('.'))
except OSError:
return True
try:
os.listdir(b'\\\\?\\C:' + b'\\' * 300)
except TypeError:
return True
except OSError:
return False
xfailif_broken_deep_listdir = pytest.mark.xfail(
broken_deep_listdir(),
reason='Node on windows requires deep listdir',
)
xfailif_no_symlink = pytest.mark.xfail(
not hasattr(os, 'symlink'),
reason='Symlink is not supported on this platform',

View File

@@ -32,7 +32,6 @@ from testing.util import cwd
from testing.util import get_resource_path
from testing.util import skipif_cant_run_docker
from testing.util import skipif_cant_run_swift
from testing.util import xfailif_broken_deep_listdir
from testing.util import xfailif_no_venv
from testing.util import xfailif_windows_no_ruby
@@ -230,7 +229,6 @@ def test_run_a_docker_image_hook(tempdir_factory, store, hook_id):
)
@xfailif_broken_deep_listdir
def test_run_a_node_hook(tempdir_factory, store):
_test_hook_repo(
tempdir_factory, store, 'node_hooks_repo',
@@ -238,7 +236,6 @@ def test_run_a_node_hook(tempdir_factory, store):
)
@xfailif_broken_deep_listdir
def test_run_versioned_node_hook(tempdir_factory, store):
_test_hook_repo(
tempdir_factory, store, 'node_versioned_hooks_repo',
@@ -521,7 +518,6 @@ def test_additional_ruby_dependencies_installed(tempdir_factory, store):
assert 'tins' in output
@xfailif_broken_deep_listdir # pragma: windows no cover
def test_additional_node_dependencies_installed(tempdir_factory, store):
path = make_repo(tempdir_factory, 'node_hooks_repo')
config = make_config_from_repo(path)