Skip to content

Commit e491747

Browse files
committed
Chore: Pluralize extra
1 parent eb43828 commit e491747

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/pytest_html/nextgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def pytest_runtest_logreport(self, report):
204204
test_index = hasattr(report, "rerun") and report.rerun + 1 or 0
205205

206206
# TODO rename to "extras" since list
207-
report_extras = getattr(report, "extra", [])
207+
report_extras = getattr(report, "extras", [])
208208
for extra_index, extra in enumerate(report_extras):
209209
content = extra["content"]
210210
asset_name = self._asset_filename(test_id, extra_index, test_index, extra['extension'])

src/pytest_html/plugin.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44
import pytest
5+
import warnings
56
from pathlib import Path
67

78
from . import extras # noqa: F401
@@ -114,8 +115,8 @@ def pytest_runtest_makereport(item, call):
114115
report = outcome.get_result()
115116
if report.when == "call":
116117
fixture_extras = getattr(item.config, "extras", [])
117-
plugin_extras = getattr(report, "extra", [])
118-
report.extra = fixture_extras + plugin_extras
118+
plugin_extras = getattr(report, "extras", [])
119+
report.extras = fixture_extras + plugin_extras
119120

120121

121122
@pytest.fixture
@@ -130,6 +131,27 @@ def extra(pytestconfig):
130131
def test_foo(extra):
131132
extra.append(pytest_html.extras.url("https://www.example.com/"))
132133
"""
134+
warnings.warn(
135+
"The 'extra' fixture is deprecated and will be removed in a future release, use 'extras' instead.",
136+
DeprecationWarning
137+
)
138+
pytestconfig.extras = []
139+
yield pytestconfig.extras
140+
del pytestconfig.extras[:]
141+
142+
143+
@pytest.fixture
144+
def extras(pytestconfig):
145+
"""Add details to the HTML reports.
146+
147+
.. code-block:: python
148+
149+
import pytest_html
150+
151+
152+
def test_foo(extras):
153+
extras.append(pytest_html.extras.url("https://www.example.com/"))
154+
"""
133155
pytestconfig.extras = []
134156
yield pytestconfig.extras
135157
del pytestconfig.extras[:]

0 commit comments

Comments
 (0)