Skip to content

Commit 758d904

Browse files
authored
Merge pull request #283 from christiansandberg/282-remove-funcargs
Remove usage of funcargs
2 parents b577d20 + 27be3f5 commit 758d904

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

pytest_html/plugin.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ def pytest_runtest_makereport(item, call):
9595
outcome = yield
9696
report = outcome.get_result()
9797
if report.when == "call":
98-
fixture_extras = item.funcargs.get("extra", [])
98+
fixture_extras = getattr(item.config, "extras", [])
9999
plugin_extras = getattr(report, "extra", [])
100100
report.extra = fixture_extras + plugin_extras
101101

102102

103103
@pytest.fixture
104-
def extra():
104+
def extra(pytestconfig):
105105
"""Add details to the HTML reports.
106106
107107
.. code-block:: python
@@ -110,7 +110,9 @@ def extra():
110110
def test_foo(extra):
111111
extra.append(pytest_html.extras.url('http://www.example.com/'))
112112
"""
113-
return []
113+
pytestconfig.extras = []
114+
yield pytestconfig.extras
115+
del pytestconfig.extras[:]
114116

115117

116118
def data_uri(content, mime_type="text/plain", charset="utf-8"):

testing/test_pytest_html.py

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

1616

17+
def handle_tr_writer_deprecation():
18+
# Remove this function when they've fixed
19+
# 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)
25+
26+
1727
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
1831
path = testdir.tmpdir.join(path)
1932
result = testdir.runpytest("--html", path, *args)
2033
return result, read_html(path)
@@ -219,6 +232,9 @@ def test_report_title(self, testdir, path):
219232
assert report_title in html
220233

221234
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()
222238
report_location = "REPORT_LOCATION"
223239
report_name = "MuhReport"
224240
monkeypatch.setenv(report_location, report_name)
@@ -878,6 +894,9 @@ def test_css_invalid(self, testdir, recwarn):
878894
assert "No such file or directory: 'style.css'" in result.stderr.str()
879895

880896
def test_css_invalid_no_html(self, testdir):
897+
# TODO: Temporary hack until they fix
898+
# https://github.com/pytest-dev/pytest/issues/6936
899+
handle_tr_writer_deprecation()
881900
testdir.makepyfile("def test_pass(): pass")
882901
result = testdir.runpytest("--css", "style.css")
883902
assert result.ret == 0

0 commit comments

Comments
 (0)