mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 00:54:42 +04:00
Incoroporate PR feedback
* Make config_file a required argument to Runner * Update main.py * Update tests to make them all green New test to test alternate config functionality coming in next commit
This commit is contained in:
parent
f1c00eefe4
commit
f205e6d170
7 changed files with 63 additions and 59 deletions
|
|
@ -15,7 +15,7 @@ from testing.fixtures import make_consuming_repo
|
|||
|
||||
def test_init_has_no_side_effects(tmpdir):
|
||||
current_wd = os.getcwd()
|
||||
runner = Runner(tmpdir.strpath)
|
||||
runner = Runner(tmpdir.strpath, C.CONFIG_FILE)
|
||||
assert runner.git_root == tmpdir.strpath
|
||||
assert os.getcwd() == current_wd
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ def test_init_has_no_side_effects(tmpdir):
|
|||
def test_create_sets_correct_directory(tempdir_factory):
|
||||
path = git_dir(tempdir_factory)
|
||||
with cwd(path):
|
||||
runner = Runner.create()
|
||||
runner = Runner.create(C.CONFIG_FILE)
|
||||
assert os.path.normcase(runner.git_root) == os.path.normcase(path)
|
||||
assert os.path.normcase(os.getcwd()) == os.path.normcase(path)
|
||||
|
||||
|
|
@ -37,20 +37,20 @@ def test_create_changes_to_git_root(tempdir_factory):
|
|||
os.chdir(foo_path)
|
||||
assert os.getcwd() != path
|
||||
|
||||
runner = Runner.create()
|
||||
runner = Runner.create(C.CONFIG_FILE)
|
||||
assert os.path.normcase(runner.git_root) == os.path.normcase(path)
|
||||
assert os.path.normcase(os.getcwd()) == os.path.normcase(path)
|
||||
|
||||
|
||||
def test_config_file_path():
|
||||
runner = Runner(os.path.join('foo', 'bar'))
|
||||
runner = Runner(os.path.join('foo', 'bar'), C.CONFIG_FILE)
|
||||
expected_path = os.path.join('foo', 'bar', C.CONFIG_FILE)
|
||||
assert runner.config_file_path == expected_path
|
||||
|
||||
|
||||
def test_repositories(tempdir_factory, mock_out_store_directory):
|
||||
path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
||||
runner = Runner(path)
|
||||
runner = Runner(path, C.CONFIG_FILE)
|
||||
assert len(runner.repositories) == 1
|
||||
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ def test_local_hooks(tempdir_factory, mock_out_store_directory):
|
|||
))
|
||||
git_path = git_dir(tempdir_factory)
|
||||
add_config_to_repo(git_path, config)
|
||||
runner = Runner(git_path)
|
||||
runner = Runner(git_path, C.CONFIG_FILE)
|
||||
assert len(runner.repositories) == 1
|
||||
assert len(runner.repositories[0].hooks) == 2
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ def test_local_hooks(tempdir_factory, mock_out_store_directory):
|
|||
def test_pre_commit_path(in_tmpdir):
|
||||
path = os.path.join('foo', 'bar')
|
||||
cmd_output('git', 'init', path)
|
||||
runner = Runner(path)
|
||||
runner = Runner(path, C.CONFIG_FILE)
|
||||
expected_path = os.path.join(path, '.git', 'hooks', 'pre-commit')
|
||||
assert runner.pre_commit_path == expected_path
|
||||
|
||||
|
|
@ -90,12 +90,12 @@ def test_pre_commit_path(in_tmpdir):
|
|||
def test_pre_push_path(in_tmpdir):
|
||||
path = os.path.join('foo', 'bar')
|
||||
cmd_output('git', 'init', path)
|
||||
runner = Runner(path)
|
||||
runner = Runner(path, C.CONFIG_FILE)
|
||||
expected_path = os.path.join(path, '.git', 'hooks', 'pre-push')
|
||||
assert runner.pre_push_path == expected_path
|
||||
|
||||
|
||||
def test_cmd_runner(mock_out_store_directory):
|
||||
runner = Runner(os.path.join('foo', 'bar'))
|
||||
runner = Runner(os.path.join('foo', 'bar'), C.CONFIG_FILE)
|
||||
ret = runner.cmd_runner
|
||||
assert ret.prefix_dir == os.path.join(mock_out_store_directory) + os.sep
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue