Skip to content

Commit

Permalink
test: check for unexpected warning/error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kalekundert committed Nov 30, 2022
1 parent ae1168d commit 77b3f81
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_autoclasstoc.nt
Expand Up @@ -660,10 +660,14 @@ test_autoclasstoc:
> child

parent.rst:
> Parent
> ======
> .. autoclass:: mock_project.Parent
> :members:

child.rst:
> Child
> =====
> .. autoclass:: mock_project.Child
> :members:
>
Expand Down Expand Up @@ -752,10 +756,14 @@ test_autoclasstoc:
> child

parent.rst:
> Parent
> ======
> .. autoclass:: mock_project.parent.Parent
> :members:

child.rst:
> Child
> =====
> .. autoclass:: mock_project.child.Child
> :members:
>
Expand Down Expand Up @@ -807,10 +815,14 @@ test_autoclasstoc:
> child

parent.rst:
> Parent
> ======
> .. autoclass:: mock_project.Parent
> :members:

child.rst:
> Child
> =====
> .. autoclass:: mock_project.Child
> :members:
>
Expand Down
19 changes: 19 additions & 0 deletions tests/test_autoclasstoc.py
Expand Up @@ -40,9 +40,28 @@ def test_autoclasstoc(tmp_files, expected, forbidden, stderr, monkeypatch, capsy

cap = capsys.readouterr()

(tmp_files / 'build' / 'stdout').write_text(cap.out)
(tmp_files / 'build' / 'stderr').write_text(cap.err)

for pattern in stderr:
re_assert.Matches(pattern).assert_matches(cap.err)

if not stderr:
expected_warnings = [
# This happens because the `autoclasstoc` directive puts a
# horizontal line after itself to separate the TOC from the
# full method descriptions. It would be easy to avoid this
# warning by putting some arbitrary text after every
# `autoclasstoc` directive, but I felt this would be too much
# of a distraction from the tests themselves.
'Document may not end with a transition.',
]
unexpected_warnings = [
line for line in cap.err.splitlines()
if not any(warning in line for warning in expected_warnings)
]
assert not unexpected_warnings

# Check the HTML results:

html_paths = [*expected.keys(), *forbidden.keys()]
Expand Down

0 comments on commit 77b3f81

Please sign in to comment.