From 071dbfeb4d3163f598eaf8ec317373c8499956b7 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Fri, 21 Aug 2020 18:35:31 +0200 Subject: [PATCH] support/tests: add runtime test for python-rpi-gpio Modeled after similar python packages. However, this one is picky, and throws an exception when it detects that it is not running on a Raspberry Pi. So we just catch that exception and check this is what we expect. Signed-off-by: Yann E. MORIN Cc: Christian Stewart Cc: Michael Fischer Cc: Asaf Kahlon Cc: Yegor Yefremov Cc: Ian Haylock Signed-off-by: Thomas Petazzoni --- .../testing/tests/package/sample_python_rpi_gpio.py | 6 ++++++ support/testing/tests/package/test_python_rpi_gpio.py | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 support/testing/tests/package/sample_python_rpi_gpio.py create mode 100644 support/testing/tests/package/test_python_rpi_gpio.py diff --git a/support/testing/tests/package/sample_python_rpi_gpio.py b/support/testing/tests/package/sample_python_rpi_gpio.py new file mode 100644 index 0000000000..5f0d884e07 --- /dev/null +++ b/support/testing/tests/package/sample_python_rpi_gpio.py @@ -0,0 +1,6 @@ +try: + import RPi.GPIO # noqa +except RuntimeError as e: + assert(str(e) == 'This module can only be run on a Raspberry Pi!') +else: + raise RuntimeError('Import succeeded when it should not have!') diff --git a/support/testing/tests/package/test_python_rpi_gpio.py b/support/testing/tests/package/test_python_rpi_gpio.py new file mode 100644 index 0000000000..c938ea39bb --- /dev/null +++ b/support/testing/tests/package/test_python_rpi_gpio.py @@ -0,0 +1,11 @@ +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonPy3RpiGpio(TestPythonPackageBase): + __test__ = True + config = TestPythonPackageBase.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_RPI_GPIO=y + """ + sample_scripts = ["tests/package/sample_python_rpi_gpio.py"] -- 2.30.2