Skip to content

Commit 86a16b3

Browse files
Merge pull request #258 from adamtheturtle/better-warnings
Fail tests if there are unexpected warnings
2 parents e20e2b9 + dbe1047 commit 86a16b3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies = [
4444
]
4545
optional-dependencies.dev = [
4646
"actionlint-py==1.7.7.23",
47+
"anstrip==0.2.2",
4748
"check-manifest==0.50",
4849
"deptry==0.23.1",
4950
"doc8==2.0.0",

tests/test_integration.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pathlib import Path
1111
from typing import Any
1212

13+
import anstrip
1314
import pytest
1415
from beartype import beartype
1516
from sphinx.testing.util import SphinxTestApp
@@ -99,8 +100,13 @@ def _assert_rst_converts_to_notion_objects(
99100
assert app.statuscode == 0
100101

101102
warning_output = app.warning.getvalue()
102-
for expected_warning in expected_warnings:
103-
assert expected_warning in warning_output
103+
ansi_stripped_warning_output = anstrip.strip(string=warning_output)
104+
warnings = [
105+
item.strip()
106+
for item in ansi_stripped_warning_output.split(sep="WARNING: ")
107+
if item.strip()
108+
]
109+
assert list(expected_warnings) == warnings
104110

105111
output_file = app.outdir / "index.json"
106112
with output_file.open(encoding="utf-8") as f:

0 commit comments

Comments
 (0)