From: Trevor Woerner <twoerner@gmail.com>
To: yocto-patches@lists.yoctoproject.org
Subject: [wic][PATCH v4 2/6] tests: add conftest with a wic-import preflight and session banner
Date: Mon, 6 Jul 2026 18:29:00 -0400 [thread overview]
Message-ID: <20260706222904.664863-3-twoerner@gmail.com> (raw)
In-Reply-To: <20260706222904.664863-1-twoerner@gmail.com>
tests/conftest.py prepares the suite and describes the run. It adds the
in-tree src/ to sys.path so the tests import the wic in the checkout
without an install, then imports wic once up front: if that fails, the
session stops immediately with pytest.exit() and the reason, rather than
letting every test error out one by one against a missing or wrong wic.
A pytest_report_header hook prints a short banner naming the host, the
Python and pytest versions, and the wic under test with its version and
imported path, so a run can be attributed when more than one checkout or
virtualenv is in play.
AI-Generated: codex/claude-opus 4.8 (xhigh)
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
changes in v4:
- move the wic-import check here from the run-tests.sh wrapper, so
it runs on every invocation regardless of how pytest is launched;
on failure the session stops with pytest.exit().
changes in v3:
- no change in this revision.
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 | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 tests/conftest.py
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 000000000000..13b8953cec40
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,28 @@
+# Session setup and banner for the wic test suite.
+
+import platform
+import sys
+from pathlib import Path
+
+import pytest
+
+_SRC = Path(__file__).resolve().parent.parent / "src"
+if str(_SRC) not in sys.path:
+ sys.path.insert(0, str(_SRC))
+
+try:
+ import wic.cli as _wic_cli
+except Exception as exc:
+ pytest.exit("cannot import wic from %s: %s" % (_SRC, exc), returncode=1)
+
+
+def pytest_report_header(config):
+ return "\n".join([
+ "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)" % (
+ getattr(_wic_cli, "__version__", "(unknown)"), _wic_cli.__file__),
+ ])
--
2.50.0.173.g8b6f19ccfc3a
next prev parent reply other threads:[~2026-07-06 22:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 22:28 [wic][PATCH v4 0/6] tests: standalone test-suite framework plus the first unit test Trevor Woerner
2026-07-06 22:28 ` [wic][PATCH v4 1/6] tests: add the standalone unit-test suite skeleton Trevor Woerner
2026-07-06 22:29 ` Trevor Woerner [this message]
2026-07-06 22:29 ` [wic][PATCH v4 3/6] tests: add optional coverage reporting Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 4/6] add ruff linting Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 5/6] bb/utils: import errno so mkdirhier's OSError handler works Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 6/6] tests/unit/test_bb_utils: cover mkdirhier() Trevor Woerner
2026-07-08 14:27 ` [yocto-patches] [wic][PATCH v4 0/6] tests: standalone test-suite framework plus the first unit test Paul Barker
2026-07-09 3:50 ` Trevor Woerner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706222904.664863-3-twoerner@gmail.com \
--to=twoerner@gmail.com \
--cc=yocto-patches@lists.yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.