Refactored how entry points work.

This commit is contained in:
Anthony Sottile 2014-03-22 18:21:54 -07:00
parent 5db7f2d807
commit 45741545dc
8 changed files with 71 additions and 42 deletions

28
tests/util_test.py Normal file
View file

@ -0,0 +1,28 @@
import mock
import pytest
import sys
from pre_commit.util import entry
@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:]