The tests are in the 'testing_vcs' directory, so set PTEST_PYTEST_DIR
accordingly. Add setuptools, setuptools-scm, and git to the ptest
RDEPENDS, since many of the tests make use of them. Many of the skipped
tests depend on mercurial, but that's in meta-oe and not worth moving to
oe-core just for this.
Add python3-vcs-versioning to PTESTS_FAST in ptest-packagelists.inc,
since the suite only takes a few seconds.
We also need a custom run-ptest script for two reasons:
1. There is a 'vcs_versioning.test_api' used as a plugin. This is
mentioned in conftest.py but is intended to be picked up from
pyproject.toml, which we don't ship with the ptest image. Instead,
just add '-p vcs_versioning.test_api' to the pytest call.
2. The test logic tries to rewrite pytest's assertion failures, which
doesn't work well with our automake formatting. We can work around
this by telling pytest to output plain messages with --assert=plain.
Example test results:
|============================================================================
|Testsuite summary
|# TOTAL: 409
|# PASS: 364
|# SKIP: 44
|# XFAIL: 1
|# FAIL: 0
|# XPASS: 0
|# ERROR: 0
|DURATION: 3
|END: /usr/lib/python3-vcs-versioning/ptest
|2026-04-23T16:21
|STOP: ptest-runner
|TOTAL: 1 FAIL: 0
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
python3-pyyaml \
python3-rpds-py \
python3-trove-classifiers \
+ python3-vcs-versioning \
python3-uritools \
python3-wcwidth \
python3-webcolors \
--- /dev/null
+#!/bin/sh
+
+# we need to load the vcs_versioning.test_api plugin for some tests to work.
+# Also make sure that we don't get pretty diffs for assertion errors so that we
+# don't see terminalreporter errors (which the automake plugin un-registers).
+pytest -p vcs_versioning.test_api --assert=plain --automake
SRC_URI[sha256sum] = "fabd75a3cab7dd8ac02fe24a3a9ba936bf258667b5a62ed468c9a1da0f5775bc"
+SRC_URI += "\
+ file://run-ptest \
+"
+
PYPI_PACKAGE = "vcs_versioning"
+PTEST_PYTEST_DIR = "testing_vcs"
-inherit pypi python_setuptools_build_meta
+inherit pypi python_setuptools_build_meta ptest-python-pytest
DEPENDS += "\
python3-packaging-native \
python3-typing-extensions \
"
+RDEPENDS:${PN}-ptest += "\
+ git \
+ python3-setuptools \
+ python3-setuptools-scm \
+"
+
+do_install_ptest:append() {
+ rm -rf ${D}${PTEST_PATH}/.pytest_cache
+ find ${D}${PTEST_PATH} -name __pycache__ -type d -exec rm -rf {} +
+ find ${D}${PTEST_PATH} -name '*.pyc' -delete
+}
+
BBCLASSEXTEND = "native nativesdk"