mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-06 03:56:54 +00:00
coverage report command does not need to specify ignoring 100% files: it's already specified in coverage conf file.
branch name checker tests ready at 100%
This commit is contained in:
parent
284c04df70
commit
3b8aa606c1
2 changed files with 38 additions and 1 deletions
|
|
@ -3,7 +3,7 @@ ALL pre_commit_hooks tests, not only Loaderon's):
|
||||||
|
|
||||||
coverage erase
|
coverage erase
|
||||||
coverage run --source pre_commit_hooks -m pytest
|
coverage run --source pre_commit_hooks -m pytest
|
||||||
coverage report --fail-under 100
|
coverage report
|
||||||
|
|
||||||
#######################################################################################################################
|
#######################################################################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from pre_commit_hooks.loaderon_hooks.general_hooks.check_branch_name import main
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def clean_sys_argv():
|
||||||
|
sys.argv = []
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
def test_branch_name_ok():
|
||||||
|
new_branch_name = str(uuid.uuid4())
|
||||||
|
subprocess.check_output(['git', 'checkout', '-b', new_branch_name])
|
||||||
|
sys.argv.append('--regex')
|
||||||
|
sys.argv.append(r'\b(?!master)\b\S+')
|
||||||
|
|
||||||
|
result = main(sys.argv)
|
||||||
|
|
||||||
|
subprocess.check_output(['git', 'checkout', 'master'])
|
||||||
|
subprocess.check_output(['git', 'branch', '-d', new_branch_name])
|
||||||
|
|
||||||
|
assert result == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_branch_name_error():
|
||||||
|
subprocess.check_output(['git', 'checkout', 'master'])
|
||||||
|
sys.argv.append('--regex')
|
||||||
|
sys.argv.append(r'\b(?!master)\b\S+')
|
||||||
|
|
||||||
|
result = main(sys.argv)
|
||||||
|
|
||||||
|
assert result == 2
|
||||||
Loading…
Add table
Add a link
Reference in a new issue