mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Add new hook
This commit is contained in:
parent
b1a8062750
commit
7e1df7a0cb
2 changed files with 41 additions and 0 deletions
17
tests/detect_datetime_now_test.py
Normal file
17
tests/detect_datetime_now_test.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import pytest
|
||||
|
||||
from pre_commit_hooks.detect_datetime_now import main
|
||||
|
||||
TESTS = (
|
||||
('from datetime import datetime\ncurrent_date = datetime.now()', 1),
|
||||
('from datetime import datetime', 0),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('input_s', 'expected_return_value'), TESTS)
|
||||
def test_datetime_now_usage(input_s, expected_return_value, tmpdir):
|
||||
"""Test behavior with no datetime.now being used on code."""
|
||||
path = tmpdir.join('test_script.py')
|
||||
path.write(input_s)
|
||||
using_datetime = main([path.strpath])
|
||||
assert using_datetime == expected_return_value
|
||||
Loading…
Add table
Add a link
Reference in a new issue