mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 04:54:16 +00:00
Add name-tests-test hook
This commit is contained in:
parent
f19c06a8b4
commit
ab35cd3634
3 changed files with 31 additions and 0 deletions
|
|
@ -17,3 +17,9 @@
|
||||||
description: This hook trims trailing whitespace.
|
description: This hook trims trailing whitespace.
|
||||||
entry: trailing-whitespace-fixer
|
entry: trailing-whitespace-fixer
|
||||||
language: python
|
language: python
|
||||||
|
-
|
||||||
|
id: name-tests-test
|
||||||
|
name: Tests should end in _test.py
|
||||||
|
description: This verifies that test files are named correctly
|
||||||
|
entry: name-tests-test
|
||||||
|
language: python
|
||||||
24
pre_commit_hooks/tests_should_end_in_test.py
Normal file
24
pre_commit_hooks/tests_should_end_in_test.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def validate_files(argv):
|
||||||
|
retcode = 0
|
||||||
|
for filename in argv:
|
||||||
|
if (
|
||||||
|
not filename.endswith('_test.py') and
|
||||||
|
not filename.endswith('__init__.py') and
|
||||||
|
not filename.endswith('/conftest.py')
|
||||||
|
):
|
||||||
|
retcode = 1
|
||||||
|
print '{0} does not end in _test.py'.format(filename)
|
||||||
|
|
||||||
|
return retcode
|
||||||
|
|
||||||
|
|
||||||
|
def entry():
|
||||||
|
validate_files(sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(entry())
|
||||||
1
setup.py
1
setup.py
|
|
@ -15,6 +15,7 @@ setup(
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
'debug-statement-hook = pre_commit_hooks.debug_statement_hook:entry',
|
'debug-statement-hook = pre_commit_hooks.debug_statement_hook:entry',
|
||||||
'trailing-whitespace-fixer = pre_commit_hooks.trailing_whitespace_fixer:entry',
|
'trailing-whitespace-fixer = pre_commit_hooks.trailing_whitespace_fixer:entry',
|
||||||
|
'name-tests-test = pre_commit_hooks.tests_should_end_in_test:entry',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue