Avoid use of __multicall__ in pytest_runtest_makereport
This commit is contained in:
parent
741ee26139
commit
0500aa622f
|
@ -62,9 +62,12 @@ conftest.py file:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
def pytest_runtest_makereport(__multicall__, item):
|
||||
import pytest
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
pytest_html = item.config.pluginmanager.getplugin('html')
|
||||
report = __multicall__.execute()
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
extra = getattr(report, 'extra', [])
|
||||
if report.when == 'call':
|
||||
# always add url to report
|
||||
|
@ -74,7 +77,6 @@ conftest.py file:
|
|||
# only add additional html on failure
|
||||
extra.append(pytest_html.extras.html('<div>Additional HTML</div>'))
|
||||
report.extra = extra
|
||||
return report
|
||||
|
||||
Screenshots
|
||||
-----------
|
||||
|
|
|
@ -163,12 +163,14 @@ class TestHTML:
|
|||
def test_extra_html(self, testdir):
|
||||
content = str(random.random())
|
||||
testdir.makeconftest("""
|
||||
def pytest_runtest_makereport(__multicall__, item):
|
||||
report = __multicall__.execute()
|
||||
import pytest
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
if report.when == 'call':
|
||||
from pytest_html import extras
|
||||
report.extra = [extras.html('<div>{0}</div>')]
|
||||
return report
|
||||
""".format(content))
|
||||
testdir.makepyfile('def test_pass(): pass')
|
||||
result, html = run(testdir)
|
||||
|
@ -178,12 +180,14 @@ class TestHTML:
|
|||
def test_extra_text(self, testdir):
|
||||
content = str(random.random())
|
||||
testdir.makeconftest("""
|
||||
def pytest_runtest_makereport(__multicall__, item):
|
||||
report = __multicall__.execute()
|
||||
import pytest
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
if report.when == 'call':
|
||||
from pytest_html import extras
|
||||
report.extra = [extras.text('{0}')]
|
||||
return report
|
||||
""".format(content))
|
||||
testdir.makepyfile('def test_pass(): pass')
|
||||
result, html = run(testdir)
|
||||
|
@ -200,12 +204,14 @@ class TestHTML:
|
|||
def test_extra_url(self, testdir):
|
||||
content = str(random.random())
|
||||
testdir.makeconftest("""
|
||||
def pytest_runtest_makereport(__multicall__, item):
|
||||
report = __multicall__.execute()
|
||||
import pytest
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
if report.when == 'call':
|
||||
from pytest_html import extras
|
||||
report.extra = [extras.url('{0}')]
|
||||
return report
|
||||
""".format(content))
|
||||
testdir.makepyfile('def test_pass(): pass')
|
||||
result, html = run(testdir)
|
||||
|
@ -217,12 +223,14 @@ class TestHTML:
|
|||
def test_extra_image(self, testdir):
|
||||
content = str(random.random())
|
||||
testdir.makeconftest("""
|
||||
def pytest_runtest_makereport(__multicall__, item):
|
||||
report = __multicall__.execute()
|
||||
import pytest
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
if report.when == 'call':
|
||||
from pytest_html import extras
|
||||
report.extra = [extras.image('{0}')]
|
||||
return report
|
||||
""".format(content))
|
||||
testdir.makepyfile('def test_pass(): pass')
|
||||
result, html = run(testdir)
|
||||
|
@ -234,12 +242,14 @@ class TestHTML:
|
|||
def test_extra_json(self, testdir):
|
||||
content = {str(random.random()): str(random.random())}
|
||||
testdir.makeconftest("""
|
||||
def pytest_runtest_makereport(__multicall__, item):
|
||||
report = __multicall__.execute()
|
||||
import pytest
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
if report.when == 'call':
|
||||
from pytest_html import extras
|
||||
report.extra = [extras.json({0})]
|
||||
return report
|
||||
""".format(content))
|
||||
testdir.makepyfile('def test_pass(): pass')
|
||||
result, html = run(testdir)
|
||||
|
|
Loading…
Reference in New Issue