Skip to content

Commit afa80df

Browse files
committed
add tests for nitpick_ignore_regex
1 parent 0aea6d3 commit afa80df

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/test_config.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,46 @@ def test_nitpick_base(app, status, warning):
342342
def test_nitpick_ignore(app, status, warning):
343343
app.builder.build_all()
344344
assert not len(warning.getvalue().strip())
345+
346+
347+
@pytest.mark.sphinx(testroot='nitpicky-warnings', confoverrides={
348+
'nitpick_ignore_regex': [
349+
(r'py:.*', r'.*postfix'),
350+
(r'.*:class', r'prefix.*'),
351+
]
352+
})
353+
def test_nitpick_ignore_regex1(app, status, warning):
354+
app.builder.build_all()
355+
assert not len(warning.getvalue().strip())
356+
357+
358+
@pytest.mark.sphinx(testroot='nitpicky-warnings', confoverrides={
359+
'nitpick_ignore_regex': [
360+
(r'py:.*', r'prefix.*'),
361+
(r'.*:class', r'.*postfix'),
362+
]
363+
})
364+
def test_nitpick_ignore_regex2(app, status, warning):
365+
app.builder.build_all()
366+
assert not len(warning.getvalue().strip())
367+
368+
369+
@pytest.mark.sphinx(testroot='nitpicky-warnings', confoverrides={
370+
'nitpick_ignore_regex': [
371+
# None of these should match
372+
(r'py:', r'.*'),
373+
(r':class', r'.*'),
374+
(r'', r'.*'),
375+
(r'.*', r'anything'),
376+
(r'.*', r'prefix'),
377+
(r'.*', r'postfix'),
378+
(r'.*', r''),
379+
]
380+
})
381+
def test_nitpick_ignore_regex_fullmatch(app, status, warning):
382+
app.builder.build_all()
383+
384+
warning = warning.getvalue().strip().split('\n')
385+
assert len(warning) == len(nitpick_warnings)
386+
for actual, expected in zip(warning, nitpick_warnings):
387+
assert expected in actual

0 commit comments

Comments
 (0)