forked from pre-commit/pre-commit-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from __future__ import annotations | ||
|
||
import os.path | ||
import re | ||
|
||
import pytest | ||
|
||
from pre_commit_hooks.check_yaml import yaml | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def hook_re(): | ||
here = os.path.dirname(__file__) | ||
with open(os.path.join(here, '..', '.pre-commit-hooks.yaml')) as f: | ||
hook_defs = yaml.load(f) | ||
hook, = ( | ||
hook | ||
for hook in hook_defs | ||
if hook['id'] == 'check-illegal-windows-names' | ||
) | ||
yield re.compile(hook['files']) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
's', | ||
( | ||
pytest.param('aux.txt', id='with ext'), | ||
pytest.param('aux', id='without ext'), | ||
pytest.param('AuX.tXt', id='capitals'), | ||
pytest.param('com7.dat', id='com with digit'), | ||
), | ||
) | ||
def test_check_illegal_windows_names_matches(hook_re, s): | ||
assert hook_re.search(s) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
's', | ||
( | ||
pytest.param('README.md', id='standard file'), | ||
pytest.param('foo.aux', id='as ext'), | ||
pytest.param('com.dat', id='com without digit'), | ||
), | ||
) | ||
def test_check_illegal_windows_names_does_not_match(hook_re, s): | ||
assert hook_re.search(s) is None |