From 612a4b18cf943fdd01c64087b7c044e4ea61c71b Mon Sep 17 00:00:00 2001 From: Rich Rauenzahn Date: Wed, 4 Dec 2019 11:45:21 -0800 Subject: [PATCH 1/2] fix regular expression for test files --- pre_commit_hooks/tests_should_end_in_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit_hooks/tests_should_end_in_test.py b/pre_commit_hooks/tests_should_end_in_test.py index 7a1e7c0..d93595f 100644 --- a/pre_commit_hooks/tests_should_end_in_test.py +++ b/pre_commit_hooks/tests_should_end_in_test.py @@ -18,7 +18,7 @@ def main(argv=None): # type: (Optional[Sequence[str]]) -> int args = parser.parse_args(argv) retcode = 0 - test_name_pattern = 'test.*.py' if args.django else '.*_test.py' + test_name_pattern = r'test.*\.py' if args.django else r'.*_test\.py' for filename in args.filenames: base = os.path.basename(filename) if ( From 3724c8f668b0c06a0d231d807ad3f90c6c89730d Mon Sep 17 00:00:00 2001 From: Rich Rauenzahn Date: Wed, 4 Dec 2019 15:06:32 -0800 Subject: [PATCH 2/2] add unit test for correct regex --- tests/tests_should_end_in_test_test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/tests_should_end_in_test_test.py b/tests/tests_should_end_in_test_test.py index 2acfa17..4df2963 100644 --- a/tests/tests_should_end_in_test_test.py +++ b/tests/tests_should_end_in_test_test.py @@ -11,6 +11,10 @@ def test_main_one_fails(): 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',