mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 21:04:17 +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
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pre_commit.util import cmd_output
|
|
||||||
|
|
||||||
from pre_commit_hooks.forbid_new_submodules import main
|
from pre_commit_hooks.forbid_new_submodules import main
|
||||||
|
|
||||||
|
|
@ -9,13 +10,13 @@ from pre_commit_hooks.forbid_new_submodules import main
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def git_dir_with_git_dir(tmpdir):
|
def git_dir_with_git_dir(tmpdir):
|
||||||
with tmpdir.as_cwd():
|
with tmpdir.as_cwd():
|
||||||
cmd_output('git', 'init', '.')
|
subprocess.check_call(('git', 'init', '.'))
|
||||||
cmd_output(
|
subprocess.check_call((
|
||||||
'git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign',
|
|
||||||
)
|
|
||||||
cmd_output('git', 'init', 'foo')
|
|
||||||
cmd_output(
|
|
||||||
'git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign',
|
'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,
|
cwd=tmpdir.join('foo').strpath,
|
||||||
)
|
)
|
||||||
yield
|
yield
|
||||||
|
|
@ -31,7 +32,7 @@ def git_dir_with_git_dir(tmpdir):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_main_new_submodule(git_dir_with_git_dir, capsys, cmd):
|
def test_main_new_submodule(git_dir_with_git_dir, capsys, cmd):
|
||||||
cmd_output(*cmd)
|
subprocess.check_call(cmd)
|
||||||
assert main() == 1
|
assert main() == 1
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert out.startswith('foo: new submodule introduced\n')
|
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):
|
def test_main_no_new_submodule(git_dir_with_git_dir):
|
||||||
open('test.py', 'a+').close()
|
open('test.py', 'a+').close()
|
||||||
cmd_output('git', 'add', 'test.py')
|
subprocess.check_call(('git', 'add', 'test.py'))
|
||||||
assert main() == 0
|
assert main() == 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue