support/testing: new python-pydantic-settings runtime test

Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
(cherry picked from commit 5eb46878bd)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
This commit is contained in:
Marcus Hoffmann
2025-05-14 17:12:46 +02:00
committed by Thomas Perale
parent b1ea70d9ea
commit ae31c77be3
3 changed files with 45 additions and 0 deletions

View File

@@ -2259,10 +2259,12 @@ F: package/python-ruamel-yaml-clib/
F: package/python-waitress/
F: support/testing/tests/package/test_python_fastapi.py
F: support/testing/tests/package/test_python_pydantic.py
F: support/testing/tests/package/test_python_pydantic_settings.py
F: support/testing/tests/package/test_python_ruamel_yaml.py
F: support/testing/tests/package/test_python_waitress.py
F: support/testing/tests/package/sample_python_fastapi.py
F: support/testing/tests/package/sample_python_pydantic.py
F: support/testing/tests/package/sample_python_pydantic_settings.py
F: support/testing/tests/package/sample_python_ruamel_yaml.py
N: Marek Belisko <marek.belisko@open-nandra.com>

View File

@@ -0,0 +1,8 @@
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
api_key: str
assert Settings().api_key == "ABCD1234"

View File

@@ -0,0 +1,35 @@
import os
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy3PydanticSettings(TestPythonPackageBase):
__test__ = True
config = """
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_PYDANTIC_SETTINGS=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
sample_scripts = ["tests/package/sample_python_pydantic_settings.py"]
timeout = 30
def login(self):
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(
arch="armv7", kernel="builtin", options=["-initrd", cpio_file]
)
self.emulator.login()
def run_sample_scripts(self):
"""Run sample script while setting an environment variable"""
for script in self.sample_scripts:
cmd = (
"api_key=ABCD1234 " + self.interpreter + " " + os.path.basename(script)
)
self.assertRunOk(cmd, timeout=self.timeout)