2
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
4
import pytest
5
+ import warnings
5
6
from pathlib import Path
6
7
7
8
from . import extras # noqa: F401
@@ -114,8 +115,8 @@ def pytest_runtest_makereport(item, call):
114
115
report = outcome .get_result ()
115
116
if report .when == "call" :
116
117
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
119
120
120
121
121
122
@pytest .fixture
@@ -130,6 +131,27 @@ def extra(pytestconfig):
130
131
def test_foo(extra):
131
132
extra.append(pytest_html.extras.url("https://www.example.com/"))
132
133
"""
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
+ """
133
155
pytestconfig .extras = []
134
156
yield pytestconfig .extras
135
157
del pytestconfig .extras [:]
0 commit comments