Skip to content

Commit 2af0b0b

Browse files
committed
better no-cover for windows
1 parent 8c550d0 commit 2af0b0b

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

pre_commit/file_lock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ def _locked(fileno, blocked_cb):
4141
# "Regions should be locked only briefly and should be unlocked
4242
# before closing a file or exiting the program."
4343
msvcrt.locking(fileno, msvcrt.LK_UNLCK, _region)
44-
except ImportError: # pragma: no cover (posix)
44+
except ImportError: # pragma: windows no cover
4545
import fcntl
4646

4747
@contextlib.contextmanager
4848
def _locked(fileno, blocked_cb):
4949
try:
5050
fcntl.flock(fileno, fcntl.LOCK_EX | fcntl.LOCK_NB)
51-
except IOError:
51+
except IOError: # pragma: no cover (tests are single-threaded)
5252
blocked_cb()
5353
fcntl.flock(fileno, fcntl.LOCK_EX)
5454
try:

pre_commit/languages/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_env_patch(venv):
2828
install_prefix = r'{}\bin'.format(win_venv.strip())
2929
elif sys.platform == 'win32': # pragma: no cover
3030
install_prefix = bin_dir(venv)
31-
else:
31+
else: # pragma: windows no cover
3232
install_prefix = venv
3333
return (
3434
('NODE_VIRTUAL_ENV', venv),

tests/commands/install_uninstall_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_install_refuses_core_hookspath(in_git_dir, store):
8484
assert install(C.CONFIG_FILE, store)
8585

8686

87-
@xfailif_no_symlink # pragma: no cover (non-windows)
87+
@xfailif_no_symlink # pragma: windows no cover
8888
def test_install_hooks_dead_symlink(in_git_dir, store):
8989
hook = in_git_dir.join('.git/hooks').ensure_dir().join('pre-commit')
9090
os.symlink('/fake/baz', hook.strpath)

tests/commands/run_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ def test_include_exclude_base_case(some_filenames):
781781
]
782782

783783

784-
@xfailif_no_symlink
785-
def test_matches_broken_symlink(tmpdir): # pragma: no cover (non-windows)
784+
@xfailif_no_symlink # pragma: windows no cover
785+
def test_matches_broken_symlink(tmpdir):
786786
with tmpdir.as_cwd():
787787
os.symlink('does-not-exist', 'link')
788788
ret = _filter_by_include_exclude({'link'}, '', '^$')

tests/languages/python_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_norm_version_expanduser():
1111
if os.name == 'nt': # pragma: no cover (nt)
1212
path = r'~\python343'
1313
expected_path = r'{}\python343'.format(home)
14-
else: # pragma: no cover (non-nt)
14+
else: # pragma: windows no cover
1515
path = '~/.pyenv/versions/3.4.3/bin/python'
1616
expected_path = home + '/.pyenv/versions/3.4.3/bin/python'
1717
result = python.norm_version(path)

tests/repository_test.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,8 @@ def test_additional_dependencies_roll_forward(tempdir_factory, store):
502502
assert 'mccabe' not in cmd_output('pip', 'freeze', '-l')[1]
503503

504504

505-
@xfailif_windows_no_ruby
506-
def test_additional_ruby_dependencies_installed(
507-
tempdir_factory, store,
508-
): # pragma: no cover (non-windows)
505+
@xfailif_windows_no_ruby # pragma: windows no cover
506+
def test_additional_ruby_dependencies_installed(tempdir_factory, store):
509507
path = make_repo(tempdir_factory, 'ruby_hooks_repo')
510508
config = make_config_from_repo(path)
511509
config['hooks'][0]['additional_dependencies'] = ['thread_safe', 'tins']
@@ -518,10 +516,8 @@ def test_additional_ruby_dependencies_installed(
518516
assert 'tins' in output
519517

520518

521-
@xfailif_broken_deep_listdir
522-
def test_additional_node_dependencies_installed(
523-
tempdir_factory, store,
524-
): # pragma: no cover (non-windows)
519+
@xfailif_broken_deep_listdir # pragma: windows no cover
520+
def test_additional_node_dependencies_installed(tempdir_factory, store):
525521
path = make_repo(tempdir_factory, 'node_hooks_repo')
526522
config = make_config_from_repo(path)
527523
# Careful to choose a small package that's not depped by npm

0 commit comments

Comments
 (0)