skip nodeenv with language_version=system

This commit is contained in:
Anthony Sottile 2020-09-07 13:43:15 -07:00
parent f511afe40e
commit f8f6d150be
3 changed files with 9 additions and 34 deletions

View file

@ -1,4 +1,3 @@
import sys
from unittest import mock
import pytest
@ -11,37 +10,17 @@ from pre_commit.languages.node import get_default_version
ACTUAL_GET_DEFAULT_VERSION = get_default_version.__wrapped__
@pytest.fixture
def is_linux():
with mock.patch.object(sys, 'platform', 'linux'):
yield
@pytest.fixture
def is_win32():
with mock.patch.object(sys, 'platform', 'win32'):
yield
@pytest.fixture
def find_exe_mck():
with mock.patch.object(parse_shebang, 'find_executable') as mck:
yield mck
@pytest.mark.usefixtures('is_linux')
def test_sets_system_when_node_and_npm_are_available(find_exe_mck):
find_exe_mck.return_value = '/path/to/exe'
assert ACTUAL_GET_DEFAULT_VERSION() == 'system'
@pytest.mark.usefixtures('is_linux')
def test_uses_default_when_node_and_npm_are_not_available(find_exe_mck):
find_exe_mck.return_value = None
assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT
@pytest.mark.usefixtures('is_win32')
def test_sets_default_on_windows(find_exe_mck):
find_exe_mck.return_value = '/path/to/exe'
assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT

View file

@ -234,7 +234,6 @@ def test_run_a_docker_image_hook(tempdir_factory, store, hook_id):
)
@xfailif_windows # pragma: win32 no cover
def test_run_a_node_hook(tempdir_factory, store):
_test_hook_repo(
tempdir_factory, store, 'node_hooks_repo',
@ -260,7 +259,6 @@ def test_run_versioned_node_hook(tempdir_factory, store):
)
@xfailif_windows # pragma: win32 no cover
def test_node_hook_with_npm_userconfig_set(tempdir_factory, store, tmpdir):
cfg = tmpdir.join('cfg')
cfg.write('cache=/dne\n')
@ -541,7 +539,6 @@ def test_additional_ruby_dependencies_installed(tempdir_factory, store):
assert 'tins' in output
@xfailif_windows # pragma: win32 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)