Skip to content

Commit

Permalink
test: show test package extras in pytest report header (#2181)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews authored May 6, 2024
1 parent 7122219 commit dc35b09
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,24 @@ def pytest_report_header(config):
except metadata.PackageNotFoundError:
items.append(f"{name} (not found)")
lines.append("required packages: " + ", ".join(items))
installed = []
not_found = []
for name in extra["optional"]:
if name in processed:
continue
processed.add(name)
try:
version = metadata.version(name)
installed.append(f"{name}-{version}")
except metadata.PackageNotFoundError:
not_found.append(name)
if installed:
lines.append("optional packages: " + ", ".join(installed))
if not_found:
lines.append("optional packages not found: " + ", ".join(not_found))
for optional in ["optional", "test"]:
installed = []
not_found = []
for name in extra[optional]:
if name in processed:
continue
processed.add(name)
try:
version = metadata.version(name)
installed.append(f"{name}-{version}")
except metadata.PackageNotFoundError:
not_found.append(name)
if installed:
lines.append(f"{optional} packages: {', '.join(installed)}")
if not_found:
lines.append(
f"{optional} packages not found: {', '.join(not_found)}"
)
return "\n".join(lines)


Expand Down

0 comments on commit dc35b09

Please sign in to comment.