mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 00:54:42 +04:00
Move empty_git_dir out of pytest fixtures.
This commit is contained in:
parent
7b1230df27
commit
047a933554
10 changed files with 159 additions and 99 deletions
|
|
@ -75,7 +75,7 @@ def out_of_date_repo(python_hooks_repo):
|
|||
config_wrapped = apply_defaults([config], CONFIG_JSON_SCHEMA)
|
||||
validate_config_extra(config_wrapped)
|
||||
config = config_wrapped[0]
|
||||
local['git']('commit', '--allow-empty', '-m', 'foo')
|
||||
local['git']['commit', '--allow-empty', '-m', 'foo']()
|
||||
head_sha = get_head_sha(python_hooks_repo)
|
||||
|
||||
with open(os.path.join(python_hooks_repo, C.CONFIG_FILE), 'w') as file_obj:
|
||||
|
|
@ -125,8 +125,8 @@ def hook_disappearing_repo(python_hooks_repo):
|
|||
get_resource_path('manifest_without_foo.yaml'),
|
||||
C.MANIFEST_FILE,
|
||||
)
|
||||
local['git']('add', '.')
|
||||
local['git']('commit', '-m', 'Remove foo')
|
||||
local['git']['add', '.']()
|
||||
local['git']['commit', '-m', 'Remove foo']()
|
||||
|
||||
with open(os.path.join(python_hooks_repo, C.CONFIG_FILE), 'w') as file_obj:
|
||||
file_obj.write(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import io
|
||||
|
|
@ -8,10 +9,12 @@ import stat
|
|||
|
||||
from pre_commit.commands.install import install
|
||||
from pre_commit.runner import Runner
|
||||
from testing.fixtures import git_dir
|
||||
|
||||
|
||||
def test_install_pre_commit(empty_git_dir):
|
||||
runner = Runner(empty_git_dir)
|
||||
def test_install_pre_commit(tmpdir_factory):
|
||||
path = git_dir(tmpdir_factory)
|
||||
runner = Runner(path)
|
||||
ret = install(runner)
|
||||
assert ret == 0
|
||||
assert os.path.exists(runner.pre_commit_path)
|
||||
|
|
|
|||
|
|
@ -75,11 +75,9 @@ def test_run_all_hooks_failing(
|
|||
({'verbose': True}, ('foo.py\nHello World',), 0, True),
|
||||
({'hook': 'bash_hook'}, ('Bash hook', 'Passed'), 0, True),
|
||||
({'hook': 'nope'}, ('No hook with id `nope`',), 1, True),
|
||||
# All the files in the repo.
|
||||
# This seems kind of weird but it is beacuse py.test reuses fixtures
|
||||
(
|
||||
{'all_files': True, 'verbose': True},
|
||||
('hooks.yaml', 'bin/hook.sh', 'foo.py', 'dummy'),
|
||||
('foo.py'),
|
||||
0,
|
||||
True,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
|
@ -5,16 +6,19 @@ import os.path
|
|||
from pre_commit.runner import Runner
|
||||
from pre_commit.commands.install import install
|
||||
from pre_commit.commands.uninstall import uninstall
|
||||
from testing.fixtures import git_dir
|
||||
|
||||
|
||||
def test_uninstall_pre_commit_does_not_blow_up_when_not_there(empty_git_dir):
|
||||
runner = Runner(empty_git_dir)
|
||||
def test_uninstall_does_not_blow_up_when_not_there(tmpdir_factory):
|
||||
path = git_dir(tmpdir_factory)
|
||||
runner = Runner(path)
|
||||
ret = uninstall(runner)
|
||||
assert ret == 0
|
||||
|
||||
|
||||
def test_uninstall(empty_git_dir):
|
||||
runner = Runner(empty_git_dir)
|
||||
def test_uninstall(tmpdir_factory):
|
||||
path = git_dir(tmpdir_factory)
|
||||
runner = Runner(path)
|
||||
assert not os.path.exists(runner.pre_commit_path)
|
||||
install(runner)
|
||||
assert os.path.exists(runner.pre_commit_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue