Adding upstream version 2.9.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e8d3ba475e
commit
5f54aad01b
32 changed files with 252 additions and 75 deletions
|
@ -1,9 +1,12 @@
|
|||
import shlex
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import git
|
||||
from pre_commit import util
|
||||
from pre_commit.commands.autoupdate import _check_hooks_still_exist_at_rev
|
||||
from pre_commit.commands.autoupdate import autoupdate
|
||||
from pre_commit.commands.autoupdate import RepositoryCannotBeUpdatedError
|
||||
|
@ -173,6 +176,11 @@ def test_autoupdate_out_of_date_repo(out_of_date, tmpdir, store):
|
|||
assert cfg.read() == fmt.format(out_of_date.path, out_of_date.head_rev)
|
||||
|
||||
|
||||
def test_autoupdate_pure_yaml(out_of_date, tmpdir, store):
|
||||
with mock.patch.object(util, 'Dumper', yaml.SafeDumper):
|
||||
test_autoupdate_out_of_date_repo(out_of_date, tmpdir, store)
|
||||
|
||||
|
||||
def test_autoupdate_only_one_to_update(up_to_date, out_of_date, tmpdir, store):
|
||||
fmt = (
|
||||
'repos:\n'
|
||||
|
|
|
@ -2,24 +2,9 @@ import pytest
|
|||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit.clientlib import InvalidConfigError
|
||||
from pre_commit.commands.migrate_config import _indent
|
||||
from pre_commit.commands.migrate_config import migrate_config
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('s', 'expected'),
|
||||
(
|
||||
('', ''),
|
||||
('a', ' a'),
|
||||
('foo\nbar', ' foo\n bar'),
|
||||
('foo\n\nbar\n', ' foo\n\n bar\n'),
|
||||
('\n\n\n', '\n\n\n'),
|
||||
),
|
||||
)
|
||||
def test_indent(s, expected):
|
||||
assert _indent(s) == expected
|
||||
|
||||
|
||||
def test_migrate_config_normal_format(tmpdir, capsys):
|
||||
cfg = tmpdir.join(C.CONFIG_FILE)
|
||||
cfg.write(
|
||||
|
|
|
@ -219,6 +219,19 @@ def test_types_hook_repository(cap_out, store, tempdir_factory):
|
|||
assert b'bar.notpy' not in printed
|
||||
|
||||
|
||||
def test_types_or_hook_repository(cap_out, store, tempdir_factory):
|
||||
git_path = make_consuming_repo(tempdir_factory, 'types_or_repo')
|
||||
with cwd(git_path):
|
||||
stage_a_file('bar.notpy')
|
||||
stage_a_file('bar.pxd')
|
||||
stage_a_file('bar.py')
|
||||
ret, printed = _do_run(cap_out, store, git_path, run_opts())
|
||||
assert ret == 1
|
||||
assert b'bar.notpy' not in printed
|
||||
assert b'bar.pxd' in printed
|
||||
assert b'bar.py' in printed
|
||||
|
||||
|
||||
def test_exclude_types_hook_repository(cap_out, store, tempdir_factory):
|
||||
git_path = make_consuming_repo(tempdir_factory, 'exclude_types_repo')
|
||||
with cwd(git_path):
|
||||
|
@ -951,6 +964,27 @@ def test_classifier_does_not_normalize_backslashes_non_windows(tmpdir):
|
|||
assert classifier.filenames == [r'a/b\c']
|
||||
|
||||
|
||||
def test_classifier_empty_types_or(tmpdir):
|
||||
tmpdir.join('bar').ensure()
|
||||
os.symlink(tmpdir.join('bar'), tmpdir.join('foo'))
|
||||
with tmpdir.as_cwd():
|
||||
classifier = Classifier(('foo', 'bar'))
|
||||
for_symlink = classifier.by_types(
|
||||
classifier.filenames,
|
||||
types=['symlink'],
|
||||
types_or=[],
|
||||
exclude_types=[],
|
||||
)
|
||||
for_file = classifier.by_types(
|
||||
classifier.filenames,
|
||||
types=['file'],
|
||||
types_or=[],
|
||||
exclude_types=[],
|
||||
)
|
||||
assert for_symlink == ['foo']
|
||||
assert for_file == ['bar']
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def some_filenames():
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue