test_python_pydantic_settings.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. from tests.package.test_python import TestPythonPackageBase
  3. class TestPythonPy3PydanticSettings(TestPythonPackageBase):
  4. __test__ = True
  5. config = """
  6. BR2_arm=y
  7. BR2_cortex_a9=y
  8. BR2_ARM_ENABLE_NEON=y
  9. BR2_ARM_ENABLE_VFP=y
  10. BR2_TOOLCHAIN_EXTERNAL=y
  11. BR2_PACKAGE_PYTHON3=y
  12. BR2_PACKAGE_PYTHON_PYDANTIC_SETTINGS=y
  13. BR2_TARGET_ROOTFS_CPIO=y
  14. # BR2_TARGET_ROOTFS_TAR is not set
  15. """
  16. sample_scripts = ["tests/package/sample_python_pydantic_settings.py"]
  17. timeout = 30
  18. def login(self):
  19. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  20. self.emulator.boot(
  21. arch="armv7", kernel="builtin", options=["-initrd", cpio_file]
  22. )
  23. self.emulator.login()
  24. def run_sample_scripts(self):
  25. """Run sample script while setting an environment variable"""
  26. for script in self.sample_scripts:
  27. cmd = (
  28. "api_key=ABCD1234 " + self.interpreter + " " + os.path.basename(script)
  29. )
  30. self.assertRunOk(cmd, timeout=self.timeout)