mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-05-02 21:39:16 -05:00
Remove defaulting behavior of validate_*. It was complicated and unnecessary
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
|
||||
import __builtin__
|
||||
|
||||
import os.path
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from pre_commit import git
|
||||
from pre_commit.clientlib.validate_base import get_validator
|
||||
from pre_commit.ordereddict import OrderedDict
|
||||
from pre_commit.yaml_extensions import ordered_load
|
||||
@@ -17,12 +12,12 @@ class AdditionalValidatorError(ValueError): pass
|
||||
|
||||
@pytest.fixture
|
||||
def noop_validator():
|
||||
return get_validator('example_hooks.yaml', {}, ValueError)
|
||||
return get_validator({}, ValueError)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def array_validator():
|
||||
return get_validator('', {'type': 'array'}, ValueError)
|
||||
return get_validator({'type': 'array'}, ValueError)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -31,7 +26,6 @@ def additional_validator():
|
||||
raise AdditionalValidatorError
|
||||
|
||||
return get_validator(
|
||||
'example_hooks.yaml',
|
||||
{},
|
||||
ValueError,
|
||||
additional_validation_strategy=raises_always,
|
||||
@@ -48,14 +42,6 @@ def test_raises_for_invalid_yaml_file(noop_validator):
|
||||
noop_validator(get_resource_path('non_parseable_yaml_file.yaml'))
|
||||
|
||||
|
||||
def test_defaults_to_backup_filename(noop_validator):
|
||||
with mock.patch.object(__builtin__, 'open', side_effect=open) as mock_open:
|
||||
noop_validator()
|
||||
mock_open.assert_called_once_with(
|
||||
os.path.join(git.get_root(), 'example_hooks.yaml'), 'r',
|
||||
)
|
||||
|
||||
|
||||
def test_raises_for_failing_schema(array_validator):
|
||||
with pytest.raises(ValueError):
|
||||
array_validator(get_resource_path('valid_yaml_but_invalid_manifest.yaml'))
|
||||
@@ -67,7 +53,7 @@ def test_passes_array_schema(array_validator):
|
||||
|
||||
def test_raises_when_additional_validation_fails(additional_validator):
|
||||
with pytest.raises(AdditionalValidatorError):
|
||||
additional_validator()
|
||||
additional_validator(get_resource_path('array_yaml_file.yaml'))
|
||||
|
||||
|
||||
def test_returns_object_after_validating(noop_validator):
|
||||
|
||||
Reference in New Issue
Block a user