mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add Runner interface.
This commit is contained in:
parent
ae1d1681b2
commit
88686d298f
25 changed files with 282 additions and 148 deletions
|
|
@ -7,6 +7,7 @@ import pytest
|
|||
|
||||
from pre_commit import git
|
||||
from pre_commit.clientlib.validate_base import get_validator
|
||||
from testing.util import get_resource_path
|
||||
|
||||
|
||||
class AdditionalValidatorError(ValueError): pass
|
||||
|
|
@ -42,7 +43,7 @@ def test_raises_for_non_existent_file(noop_validator):
|
|||
|
||||
def test_raises_for_invalid_yaml_file(noop_validator):
|
||||
with pytest.raises(ValueError):
|
||||
noop_validator('tests/data/non_parseable_yaml_file.yaml')
|
||||
noop_validator(get_resource_path('non_parseable_yaml_file.yaml'))
|
||||
|
||||
|
||||
def test_defaults_to_backup_filename(noop_validator):
|
||||
|
|
@ -55,11 +56,11 @@ def test_defaults_to_backup_filename(noop_validator):
|
|||
|
||||
def test_raises_for_failing_schema(array_validator):
|
||||
with pytest.raises(ValueError):
|
||||
array_validator('tests/data/valid_yaml_but_invalid_manifest.yaml')
|
||||
array_validator(get_resource_path('valid_yaml_but_invalid_manifest.yaml'))
|
||||
|
||||
|
||||
def test_passes_array_schema(array_validator):
|
||||
array_validator('tests/data/array_yaml_file.yaml')
|
||||
array_validator(get_resource_path('array_yaml_file.yaml'))
|
||||
|
||||
|
||||
def test_raises_when_additional_validation_fails(additional_validator):
|
||||
|
|
@ -68,5 +69,5 @@ def test_raises_when_additional_validation_fails(additional_validator):
|
|||
|
||||
|
||||
def test_returns_object_after_validating(noop_validator):
|
||||
ret = noop_validator('tests/data/array_yaml_file.yaml')
|
||||
ret = noop_validator(get_resource_path('array_yaml_file.yaml'))
|
||||
assert ret == ['foo', 'bar']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue