diff mbox series

[meta-python,3/3] python3-pydantic-core: Fix ptest collection errors

Message ID 20261109094606.2418633-3-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-python,1/3] python3-propcache: Drop the PEP 517 backend test from ptests | expand

Commit Message

Khem Raj Nov. 9, 2026, 9:46 a.m. UTC
tests/test_docstrings.py imports pytest_examples and
tests/test_tzinfo.py imports pydantic, neither of which the ptest
package depends on. pytest stops at the collection errors, so no test
ran at all:

  E   ModuleNotFoundError: No module named 'pytest_examples'
  E   ModuleNotFoundError: No module named 'pydantic'

Add both. test_docstrings.py then looks for core_schema.py and
README.md relative to the source tree, so install README.md and point
it at the installed core_schema.py.

Skip the ruff lint step of the docstring examples, as python3-pydantic
does. Outside the source tree ruff doesn't treat pydantic_core as first
party and flags the import order (I001) of 23 examples, plus a couple
of style rules newer than the examples. The examples are still run.

6025 tests pass and 126 are skipped on qemux86-64.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 .../recipes-devtools/python/python3-pydantic-core_2.50.1.bb | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-pydantic-core_2.50.1.bb b/meta-python/recipes-devtools/python/python3-pydantic-core_2.50.1.bb
index e8f2317921..8530fddbd6 100644
--- a/meta-python/recipes-devtools/python/python3-pydantic-core_2.50.1.bb
+++ b/meta-python/recipes-devtools/python/python3-pydantic-core_2.50.1.bb
@@ -33,9 +33,11 @@  RDEPENDS:${PN}-ptest += "\
     python3-hypothesis \
     python3-inline-snapshot \
     python3-misc \
+    python3-pydantic \
     python3-pytest-mock \
     python3-pytest-timeout \
     python3-pytest-benchmark \
+    python3-pytest-examples \
     python3-typing-inspection \
 	python3-tzdata \
 	python3-zoneinfo \
@@ -43,6 +45,10 @@  RDEPENDS:${PN}-ptest += "\

 do_install_ptest:append () {
     cp -rf ${S}/tests/ ${D}${PTEST_PATH}/
+    install -m 0644 ${S}/README.md ${D}${PTEST_PATH}/
+    sed -i -e "s|PYDANTIC_CORE_DIR / 'python/pydantic_core/core_schema.py'|'${PYTHON_SITEPACKAGES_DIR}/pydantic_core/core_schema.py'|" \
+        -e "s/^    lint_skip = .*/    lint_skip = True/" \
+        ${D}${PTEST_PATH}/tests/test_docstrings.py
     sed -i -e "/--automake/ s/$/ -k 'not test_model_class_root_validator_wrap and not test_model_class_root_validator_before and not test_model_class_root_validator_after'/" ${D}${PTEST_PATH}/run-ptest
 }