Skip to content

fix: Report fails to render with pytest-xdist (1) #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/pytest_html/nextgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,19 @@ def pytest_collection_finish(self, session):

@pytest.hookimpl(trylast=True)
def pytest_runtest_logreport(self, report):
data = self._config.hook.pytest_report_to_serializable(
serialized_report = self._config.hook.pytest_report_to_serializable(
config=self._config, report=report
)

data = {
"duration": serialized_report["duration"],
"when": serialized_report["when"],
}

test_id = report.nodeid
if report.when != "call":
test_id += f"::{report.when}"
data["nodeid"] = test_id
data["nodeid"] = test_id

# Order here matters!
log = report.longreprtext or report.capstdout or "No log output captured."
Expand Down
6 changes: 5 additions & 1 deletion testing/test_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def run(pytester, path="report.html", *args):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")
# chrome_options.add_argument("--allow-file-access-from-files")
driver = webdriver.Remote(
command_executor="http://127.0.0.1:4444", options=chrome_options
)
Expand Down Expand Up @@ -471,3 +470,8 @@ def pytest_runtest_makereport(item, call):
assert_that(str(element)).is_equal_to(
f'<video controls="">\n<source src="{src}" type="{mime_type}"/>\n</video>'
)

def test_xdist(self, pytester):
pytester.makepyfile("def test_xdist(): pass")
page = run(pytester, "report.html", "-n1")
assert_results(page, passed=1)