summaryrefslogtreecommitdiffstats
path: root/tests/commands/run_test.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-27 16:04:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-27 16:04:10 +0000
commita971f38b11f5955f6ea4f7922233d8324a5c6753 (patch)
tree5a424740e9cee97bc1c8053fea07db935c27b659 /tests/commands/run_test.py
parentAdding upstream version 2.8.2. (diff)
downloadpre-commit-a971f38b11f5955f6ea4f7922233d8324a5c6753.tar.xz
pre-commit-a971f38b11f5955f6ea4f7922233d8324a5c6753.zip
Adding upstream version 2.9.3.upstream/2.9.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/commands/run_test.py')
-rw-r--r--tests/commands/run_test.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py
index 00b4712..914d567 100644
--- a/tests/commands/run_test.py
+++ b/tests/commands/run_test.py
@@ -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 (