new file mode 100644
@@ -0,0 +1,38 @@
+# Session banner for the wic test suite.
+#
+# Before collection, print the environment the tests exercise:
+# - the host
+# - the Python and pytest versions
+# - the wic under test (its version and the module path of its import)
+
+import platform
+
+import pytest
+
+
+def _wic_under_test():
+ """Return (version, module_path) for the wic being tested."""
+ try:
+ import wic.cli as wic_cli
+ except Exception as exc: # pragma: no cover - reported in the banner
+ return ("(import failed: %s)" % exc, "(unimported)")
+ version = getattr(wic_cli, "__version__", "(unknown)")
+ module_path = getattr(wic_cli, "__file__", "(unknown)")
+ return (version, module_path)
+
+
+def _format_banner():
+ wic_version, wic_path = _wic_under_test()
+ lines = [
+ "wic test suite",
+ " host: %s %s %s" % (
+ platform.node(), platform.system(), platform.machine()),
+ " python: %s pytest: %s" % (
+ platform.python_version(), pytest.__version__),
+ " wic: %s (%s)" % (wic_version, wic_path),
+ ]
+ return "\n".join(lines)
+
+
+def pytest_report_header(config):
+ return _format_banner()
When a test run starts it is useful to see, at a glance, exactly what is being tested: which host the run is on, which Python and pytest are in use, and -- most importantly -- which wic the suite imported and what version it reports. Without that, a passing or failing run is hard to attribute, especially when more than one wic checkout or virtualenv is in play. pytest looks for a file named conftest.py and, among other things, calls its pytest_report_header() hook to print extra lines in the session header before collection begins. This commit adds that file with a single hook that prints a short banner: - the host node name, operating system, and machine type; - the running Python version and the pytest version; - the version wic reports and the filesystem path the wic module was imported from. The wic lookup is defensive: if wic cannot be imported (for example the test extras were not installed, or the suite is being run outside the checkout) the banner says so rather than aborting the run, so the failure is visible in the header instead of as an opaque collection error. The file name conftest.py is mandatory; pytest discovers it by name, so it cannot be called anything else. AI-Generated: codex/claude-opus 4.7 (xhigh) Signed-off-by: Trevor Woerner <twoerner@gmail.com> --- changes in v2: - v1 submitted the entire test suite as a single commit; v2 breaks the work into a reviewable series, and this patch is one step of it. --- tests/conftest.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/conftest.py