Skip to content

Commit 1b67edc

Browse files
committed
Docs: Add Deprecations docs
1 parent 43175f1 commit 1b67edc

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
15-
cancel-in-progress: ${{ github.ref != github.event.repository.default_branch }}
15+
cancel-in-progress: ${{ ! contains(github.ref, github.event.repository.default_branch) }}
1616

1717
jobs:
1818
build_docs:

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ pytest-html is a plugin for `pytest`_ that generates a HTML report for test resu
1717
api_reference
1818
development
1919
changelog
20+
deprecations
2021

2122
.. _pytest: http://pytest.org

docs/user_guide.rst

+25-28
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,25 @@ You can edit the *Summary* section by using the :code:`pytest_html_results_summa
102102

103103
.. code-block:: python
104104
105-
from py.xml import html
106-
107-
108105
def pytest_html_results_summary(prefix, summary, postfix):
109106
prefix.extend(["<p>foo: bar</p>"])
110107
111108
Extra content
112109
~~~~~~~~~~~~~
113110

114-
You can add details to the HTML report by creating an 'extra' list on the
111+
You can add details to the HTML report by creating an 'extras' list on the
115112
report object. Here are the types of extra content that can be added:
116113

117114
========== ============================================
118115
Type Example
119116
========== ============================================
120-
Raw HTML ``extra.html('<div>Additional HTML</div>')``
121-
`JSON`_ ``extra.json({'name': 'pytest'})``
122-
Plain text ``extra.text('Add some simple Text')``
123-
URL ``extra.url('http://www.example.com/')``
124-
Image ``extra.image(image, mime_type='image/gif', extension='gif')``
125-
Image ``extra.image('/path/to/file.png')``
126-
Image ``extra.image('http://some_image.png')``
117+
Raw HTML ``extras.html('<div>Additional HTML</div>')``
118+
`JSON`_ ``extras.json({'name': 'pytest'})``
119+
Plain text ``extras.text('Add some simple Text')``
120+
URL ``extras.url('http://www.example.com/')``
121+
Image ``extras.image(image, mime_type='image/gif', extension='gif')``
122+
Image ``extras.image('/path/to/file.png')``
123+
Image ``extras.image('http://some_image.png')``
127124
========== ============================================
128125

129126
**Note**: When adding an image from file, the path can be either absolute
@@ -138,9 +135,9 @@ There are also convenient types for several image formats:
138135
============ ====================
139136
Image format Example
140137
============ ====================
141-
PNG ``extra.png(image)``
142-
JPEG ``extra.jpg(image)``
143-
SVG ``extra.svg(image)``
138+
PNG ``extras.png(image)``
139+
JPEG ``extras.jpg(image)``
140+
SVG ``extras.svg(image)``
144141
============ ====================
145142

146143
The following example adds the various types of extras using a
@@ -150,42 +147,44 @@ conftest.py file:
150147
.. code-block:: python
151148
152149
import pytest
150+
import pytest_html
153151
154152
155153
@pytest.hookimpl(hookwrapper=True)
156154
def pytest_runtest_makereport(item, call):
157-
pytest_html = item.config.pluginmanager.getplugin("html")
158155
outcome = yield
159156
report = outcome.get_result()
160-
extra = getattr(report, "extra", [])
157+
extras = getattr(report, "extras", [])
161158
if report.when == "call":
162159
# always add url to report
163-
extra.append(pytest_html.extras.url("http://www.example.com/"))
160+
extras.append(pytest_html.extras.url("http://www.example.com/"))
164161
xfail = hasattr(report, "wasxfail")
165162
if (report.skipped and xfail) or (report.failed and not xfail):
166163
# only add additional html on failure
167-
extra.append(pytest_html.extras.html("<div>Additional HTML</div>"))
168-
report.extra = extra
164+
extras.append(pytest_html.extras.html("<div>Additional HTML</div>"))
165+
report.extras = extras
169166
170167
You can also specify the :code:`name` argument for all types other than :code:`html` which will change the title of the
171168
created hyper link:
172169

173170
.. code-block:: python
174171
175-
extra.append(pytest_html.extras.text("some string", name="Different title"))
172+
extras.append(pytest_html.extras.text("some string", name="Different title"))
176173
177-
It is also possible to use the fixture :code:`extra` to add content directly
174+
It is also possible to use the fixture :code:`extras` to add content directly
178175
in a test function without implementing hooks. These will generally end up
179176
before any extras added by plugins.
180177

181178
.. code-block:: python
182179
183-
from pytest_html import extras
180+
import pytest_html
181+
184182
183+
def test_extra(extras):
184+
extras.append(pytest_html.extras.text("some string"))
185185
186-
def test_extra(extra):
187-
extra.append(extras.text("some string"))
188186
187+
.. _modifying-results-table:
189188

190189
Modifying the results table
191190
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -196,7 +195,6 @@ adds a sortable time column, and removes the links column:
196195

197196
.. code-block:: python
198197
199-
from datetime import datetime
200198
import pytest
201199
202200
@@ -232,9 +230,6 @@ additional HTML and log output with a notice that the log is empty:
232230

233231
.. code-block:: python
234232
235-
from py.xml import html
236-
237-
238233
def pytest_html_results_table_html(report, data):
239234
if report.passed:
240235
del data[:]
@@ -243,6 +238,8 @@ additional HTML and log output with a notice that the log is empty:
243238
Display options
244239
---------------
245240

241+
.. _render-collapsed:
242+
246243
Auto Collapsing Table Rows
247244
~~~~~~~~~~~~~~~~~~~~~~~~~~
248245

0 commit comments

Comments
 (0)