mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Add some tests for tests_should_end_in_test hook
This commit is contained in:
parent
d2e45f3400
commit
12794c1c19
3 changed files with 30 additions and 3 deletions
11
tests/conftest.py
Normal file
11
tests/conftest.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
import __builtin__
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def print_mock():
|
||||
with mock.patch.object(__builtin__, 'print', autospec=True) as mock_print:
|
||||
yield mock_print
|
||||
14
tests/tests_should_end_in_test_test.py
Normal file
14
tests/tests_should_end_in_test_test.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
from pre_commit_hooks.tests_should_end_in_test import validate_files
|
||||
|
||||
|
||||
def test_validate_files_all_pass(print_mock):
|
||||
ret = validate_files(['foo_test.py', 'bar_test.py'])
|
||||
assert ret == 0
|
||||
assert print_mock.call_count == 0
|
||||
|
||||
|
||||
def test_validate_files_one_fails(print_mock):
|
||||
ret = validate_files(['not_test_ending.py', 'foo_test.py'])
|
||||
assert ret == 1
|
||||
assert print_mock.call_count == 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue