mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Make entry points simpler
This commit is contained in:
parent
6d1a464c4f
commit
04b421978a
8 changed files with 59 additions and 31 deletions
|
|
@ -65,6 +65,7 @@ def test_run_a_hook_lots_of_files(config_for_python_pre_commit_git_repo):
|
|||
os.environ.get('slowtests', None) == 'false',
|
||||
reason="TODO: make this test not super slow",
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_run_a_node_hook(config_for_node_pre_commit_git_repo):
|
||||
repo = Repository(config_for_node_pre_commit_git_repo)
|
||||
repo.install()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
|
||||
import mock
|
||||
import pytest
|
||||
import random
|
||||
import sys
|
||||
from plumbum import local
|
||||
|
||||
from pre_commit.util import cached_property
|
||||
from pre_commit.util import entry
|
||||
from pre_commit.util import memoize_by_cwd
|
||||
|
||||
|
||||
|
|
@ -59,3 +62,25 @@ def test_memoized_by_cwd_changes_with_different_cwd(memoized_by_cwd):
|
|||
ret2 = memoized_by_cwd('baz')
|
||||
|
||||
assert ret != ret2
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def entry_func():
|
||||
@entry
|
||||
def func(argv):
|
||||
return argv
|
||||
|
||||
return func
|
||||
|
||||
|
||||
def test_explicitly_passed_argv_are_passed(entry_func):
|
||||
input = object()
|
||||
ret = entry_func(input)
|
||||
assert ret is input
|
||||
|
||||
|
||||
def test_no_arguments_passed_uses_argv(entry_func):
|
||||
argv = [1, 2, 3, 4]
|
||||
with mock.patch.object(sys, 'argv', argv):
|
||||
ret = entry_func()
|
||||
assert ret == argv[1:]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue