Skip to content

Commit 5706b91

Browse files
committed
deep listdir works in python3 on windows
1 parent 5779f93 commit 5706b91

File tree

3 files changed

+4
-30
lines changed

3 files changed

+4
-30
lines changed

pre_commit/languages/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _envdir(prefix: Prefix, version: str) -> str:
3030
return prefix.path(directory)
3131

3232

33-
def get_env_patch(venv: str) -> PatchesT: # pragma: windows no cover
33+
def get_env_patch(venv: str) -> PatchesT:
3434
if sys.platform == 'cygwin': # pragma: no cover
3535
_, win_venv, _ = cmd_output('cygpath', '-w', venv)
3636
install_prefix = fr'{win_venv.strip()}\bin'
@@ -54,14 +54,14 @@ def get_env_patch(venv: str) -> PatchesT: # pragma: windows no cover
5454
def in_env(
5555
prefix: Prefix,
5656
language_version: str,
57-
) -> Generator[None, None, None]: # pragma: windows no cover
57+
) -> Generator[None, None, None]:
5858
with envcontext(get_env_patch(_envdir(prefix, language_version))):
5959
yield
6060

6161

6262
def install_environment(
6363
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
64-
) -> None: # pragma: windows no cover
64+
) -> None:
6565
additional_dependencies = tuple(additional_dependencies)
6666
assert prefix.exists('package.json')
6767
envdir = _envdir(prefix, version)
@@ -91,6 +91,6 @@ def run_hook(
9191
hook: 'Hook',
9292
file_args: Sequence[str],
9393
color: bool,
94-
) -> Tuple[int, bytes]: # pragma: windows no cover
94+
) -> Tuple[int, bytes]:
9595
with in_env(hook.prefix, hook.language_version):
9696
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)

testing/util.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import contextlib
22
import os.path
33
import subprocess
4-
import sys
54

65
import pytest
76

@@ -46,27 +45,6 @@ def cmd_output_mocked_pre_commit_home(
4645
xfailif_windows = pytest.mark.xfail(os.name == 'nt', reason='windows')
4746

4847

49-
def broken_deep_listdir(): # pragma: no cover (platform specific)
50-
if sys.platform != 'win32':
51-
return False
52-
try:
53-
os.listdir('\\\\?\\' + os.path.abspath('.'))
54-
except OSError:
55-
return True
56-
try:
57-
os.listdir(b'\\\\?\\C:' + b'\\' * 300)
58-
except TypeError:
59-
return True
60-
except OSError:
61-
return False
62-
63-
64-
xfailif_broken_deep_listdir = pytest.mark.xfail(
65-
broken_deep_listdir(),
66-
reason='Node on windows requires deep listdir',
67-
)
68-
69-
7048
xfailif_no_symlink = pytest.mark.xfail(
7149
not hasattr(os, 'symlink'),
7250
reason='Symlink is not supported on this platform',

tests/repository_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from testing.util import get_resource_path
3333
from testing.util import skipif_cant_run_docker
3434
from testing.util import skipif_cant_run_swift
35-
from testing.util import xfailif_broken_deep_listdir
3635
from testing.util import xfailif_no_venv
3736
from testing.util import xfailif_windows_no_ruby
3837

@@ -230,15 +229,13 @@ def test_run_a_docker_image_hook(tempdir_factory, store, hook_id):
230229
)
231230

232231

233-
@xfailif_broken_deep_listdir
234232
def test_run_a_node_hook(tempdir_factory, store):
235233
_test_hook_repo(
236234
tempdir_factory, store, 'node_hooks_repo',
237235
'foo', [os.devnull], b'Hello World\n',
238236
)
239237

240238

241-
@xfailif_broken_deep_listdir
242239
def test_run_versioned_node_hook(tempdir_factory, store):
243240
_test_hook_repo(
244241
tempdir_factory, store, 'node_versioned_hooks_repo',
@@ -521,7 +518,6 @@ def test_additional_ruby_dependencies_installed(tempdir_factory, store):
521518
assert 'tins' in output
522519

523520

524-
@xfailif_broken_deep_listdir # pragma: windows no cover
525521
def test_additional_node_dependencies_installed(tempdir_factory, store):
526522
path = make_repo(tempdir_factory, 'node_hooks_repo')
527523
config = make_config_from_repo(path)

0 commit comments

Comments
 (0)