Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 112e071

Browse files
committed
Add test for --match with path arguments
1 parent e706887 commit 112e071

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/tests/test_integration.py

+22
Original file line numberDiff line numberDiff line change
@@ -1489,3 +1489,25 @@ def test_comment_with_noqa_plus_docstring_file(env):
14891489
out, _, code = env.invoke()
14901490
assert '' == out
14911491
assert code == 0
1492+
1493+
1494+
def test_match_considers_basenames_for_path_args(env):
1495+
"""Test that `match` option only considers basenames for path arguments.
1496+
1497+
The test environment consists of a single empty module `test_a.py`. The
1498+
match option is set to a pattern that ignores test_ prefixed .py filenames.
1499+
When pydocstyle is invoked with full path to `test_a.py`, we expect it to
1500+
succeed since match option will match against just the file name and not
1501+
full path.
1502+
"""
1503+
# Ignore .py files prefixed with 'test_'
1504+
env.write_config(select='D100', match='(?!test_).+.py')
1505+
1506+
# Create an empty module (violates D100)
1507+
with env.open('test_a.py', 'wt') as test:
1508+
test.write('')
1509+
1510+
# env.invoke calls pydocstyle with full path to test_a.py
1511+
out, _, code = env.invoke(target='test_a.py')
1512+
assert '' == out
1513+
assert code == 0

0 commit comments

Comments
 (0)