Skip to content

Commit fe7b622

Browse files
authored
Merge branch 'master' into fix-missing-image
2 parents fea4eb3 + 51f50f5 commit fe7b622

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

testing/test_pytest_html.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@
1414
pytest_plugins = ("pytester",)
1515

1616

17-
def handle_tr_writer_deprecation():
18-
# Remove this function when they've fixed
17+
def remove_deprecation_from_recwarn(recwarn):
18+
# TODO: Temporary hack until they fix
1919
# https://github.com/pytest-dev/pytest/issues/6936
20-
import warnings
21-
from _pytest.warnings import _setoption
22-
23-
arg = "ignore:TerminalReporter.writer:pytest.PytestDeprecationWarning"
24-
_setoption(warnings, arg)
20+
return [
21+
item for item in recwarn if "TerminalReporter.writer" not in repr(item.message)
22+
]
2523

2624

2725
def run(testdir, path="report.html", *args):
28-
# TODO: Temporary hack until they fix
29-
# https://github.com/pytest-dev/pytest/issues/6936
30-
handle_tr_writer_deprecation() # TODO: Temporary hack
3126
path = testdir.tmpdir.join(path)
3227
result = testdir.runpytest("--html", path, *args)
3328
return result, read_html(path)
@@ -232,9 +227,6 @@ def test_report_title(self, testdir, path):
232227
assert report_title in html
233228

234229
def test_report_title_addopts_env_var(self, testdir, monkeypatch):
235-
# TODO: Temporary hack until they fix
236-
# https://github.com/pytest-dev/pytest/issues/6936
237-
handle_tr_writer_deprecation()
238230
report_location = "REPORT_LOCATION"
239231
report_name = "MuhReport"
240232
monkeypatch.setenv(report_location, report_name)
@@ -885,7 +877,8 @@ def test_css(self, testdir, recwarn, colors):
885877
cssargs.extend(["--css", path])
886878
result, html = run(testdir, "report.html", "--self-contained-html", *cssargs)
887879
assert result.ret == 0
888-
assert len(recwarn) == 0
880+
warnings = remove_deprecation_from_recwarn(recwarn)
881+
assert len(warnings) == 0
889882
for k, v in css.items():
890883
assert str(v["path"]) in html
891884
assert v["style"] in html
@@ -898,9 +891,6 @@ def test_css_invalid(self, testdir, recwarn):
898891
assert "No such file or directory: 'style.css'" in result.stderr.str()
899892

900893
def test_css_invalid_no_html(self, testdir):
901-
# TODO: Temporary hack until they fix
902-
# https://github.com/pytest-dev/pytest/issues/6936
903-
handle_tr_writer_deprecation()
904894
testdir.makepyfile("def test_pass(): pass")
905895
result = testdir.runpytest("--css", "style.css")
906896
assert result.ret == 0

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ exclude = .eggs,.tox
2727

2828
[pytest]
2929
testpaths = testing
30+
# TODO: Temporary hack until they fix
31+
# https://github.com/pytest-dev/pytest/issues/6936
32+
filterwarnings =
33+
ignore:.*TerminalReporter.writer attribute is deprecated.*:pytest.PytestDeprecationWarning

0 commit comments

Comments
 (0)