mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-29 10:16:52 +00:00
Use subprocess directly
This commit is contained in:
parent
08e2918d60
commit
69f2da629e
1 changed files with 10 additions and 9 deletions
|
|
@ -1,7 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
from pre_commit.util import cmd_output
|
||||
|
||||
from pre_commit_hooks.forbid_new_submodules import main
|
||||
|
||||
|
|
@ -9,13 +10,13 @@ from pre_commit_hooks.forbid_new_submodules import main
|
|||
@pytest.fixture
|
||||
def git_dir_with_git_dir(tmpdir):
|
||||
with tmpdir.as_cwd():
|
||||
cmd_output('git', 'init', '.')
|
||||
cmd_output(
|
||||
'git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign',
|
||||
)
|
||||
cmd_output('git', 'init', 'foo')
|
||||
cmd_output(
|
||||
subprocess.check_call(('git', 'init', '.'))
|
||||
subprocess.check_call((
|
||||
'git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign',
|
||||
))
|
||||
subprocess.check_call(('git', 'init', 'foo'))
|
||||
subprocess.check_call(
|
||||
('git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign'),
|
||||
cwd=tmpdir.join('foo').strpath,
|
||||
)
|
||||
yield
|
||||
|
|
@ -31,7 +32,7 @@ def git_dir_with_git_dir(tmpdir):
|
|||
),
|
||||
)
|
||||
def test_main_new_submodule(git_dir_with_git_dir, capsys, cmd):
|
||||
cmd_output(*cmd)
|
||||
subprocess.check_call(cmd)
|
||||
assert main() == 1
|
||||
out, _ = capsys.readouterr()
|
||||
assert out.startswith('foo: new submodule introduced\n')
|
||||
|
|
@ -39,5 +40,5 @@ def test_main_new_submodule(git_dir_with_git_dir, capsys, cmd):
|
|||
|
||||
def test_main_no_new_submodule(git_dir_with_git_dir):
|
||||
open('test.py', 'a+').close()
|
||||
cmd_output('git', 'add', 'test.py')
|
||||
subprocess.check_call(('git', 'add', 'test.py'))
|
||||
assert main() == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue