summaryrefslogtreecommitdiffstats
path: root/tests/tests_should_end_in_test_test.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-30 11:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:41:55 +0000
commitd4583dcad7d68d3c1503b04ec0d3364809304807 (patch)
tree82456c5d0bc77961759812ddd85414435ba89127 /tests/tests_should_end_in_test_test.py
parentInitial commit. (diff)
downloadpre-commit-hooks-upstream/4.5.0+dfsg.tar.xz
pre-commit-hooks-upstream/4.5.0+dfsg.zip
Adding upstream version 4.5.0+dfsg.upstream/4.5.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/tests_should_end_in_test_test.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/tests_should_end_in_test_test.py b/tests/tests_should_end_in_test_test.py
new file mode 100644
index 0000000..2b5a0de
--- /dev/null
+++ b/tests/tests_should_end_in_test_test.py
@@ -0,0 +1,50 @@
+from __future__ import annotations
+
+from pre_commit_hooks.tests_should_end_in_test import main
+
+
+def test_main_all_pass():
+ ret = main(['foo_test.py', 'bar_test.py'])
+ assert ret == 0
+
+
+def test_main_one_fails():
+ ret = main(['not_test_ending.py', 'foo_test.py'])
+ assert ret == 1
+
+
+def test_regex():
+ assert main(('foo_test_py',)) == 1
+
+
+def test_main_django_all_pass():
+ ret = main((
+ '--django', 'tests.py', 'test_foo.py', 'test_bar.py',
+ 'tests/test_baz.py',
+ ))
+ assert ret == 0
+
+
+def test_main_django_one_fails():
+ ret = main(['--django', 'not_test_ending.py', 'test_foo.py'])
+ assert ret == 1
+
+
+def test_validate_nested_files_django_one_fails():
+ ret = main(['--django', 'tests/not_test_ending.py', 'test_foo.py'])
+ assert ret == 1
+
+
+def test_main_not_django_fails():
+ ret = main(['foo_test.py', 'bar_test.py', 'test_baz.py'])
+ assert ret == 1
+
+
+def test_main_django_fails():
+ ret = main(['--django', 'foo_test.py', 'test_bar.py', 'test_baz.py'])
+ assert ret == 1
+
+
+def test_main_pytest_test_first():
+ assert main(['--pytest-test-first', 'test_foo.py']) == 0
+ assert main(['--pytest-test-first', 'foo_test.py']) == 1