diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-06-12 12:15:09 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-05-10 15:02:24 -0500 |
commit | 8a33db6022e56b3a94033695fe5c2da3b476a7e2 (patch) | |
tree | 8f1c7fda73c2bc4b480f404d983c6be1a3610e8c /host/tests/devtest/python_api_test.py | |
parent | 509b3b096123e7a6e906849121a64a9bdf51a0e9 (diff) | |
download | uhd-8a33db6022e56b3a94033695fe5c2da3b476a7e2.tar.gz uhd-8a33db6022e56b3a94033695fe5c2da3b476a7e2.tar.bz2 uhd-8a33db6022e56b3a94033695fe5c2da3b476a7e2.zip |
devtest: Make Python tests their own type of devtest
Like the example test, the Python-based test is now codified. The
"special sauce" for Python tests revolves around the fact that they
require the Python API, so we have to gracefully fail if the Python API
was never enabled, but hard-fail when the Python API is enabled, but not
working.
This creates a new type of devtest (UHDPythonTestCase) and moves
uhd_python_api_test over to the new type.
Diffstat (limited to 'host/tests/devtest/python_api_test.py')
-rw-r--r-- | host/tests/devtest/python_api_test.py | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/host/tests/devtest/python_api_test.py b/host/tests/devtest/python_api_test.py index 3e51be7d5..ef7a3ca1b 100644 --- a/host/tests/devtest/python_api_test.py +++ b/host/tests/devtest/python_api_test.py @@ -8,35 +8,16 @@ import os from uhd_test_base import shell_application -from uhd_test_base import uhd_test_case -try: - import uhd -except ImportError: - uhd = None +from uhd_test_base import UHDPythonTestCase -# For what we're doing here, ruamel.yaml and yaml are compatible, and we'll use -# whatever we can find -try: - from ruamel import yaml -except: - import yaml - - -class uhd_python_api_test(uhd_test_case): +class uhd_python_api_test(UHDPythonTestCase): """ Run multi_usrp_test """ - def test_api(self): + test_name = 'uhd_python_api_test' + + def run_test(self, test_name, test_args): """ Run test and report results. """ - if uhd is None: - print("UHD module not found -- checking for Python API") - config_info_app = shell_application('uhd_config_info') - config_info_app.run(['--enabled-components']) - if "Python API" in config_info_app.stdout: - raise RuntimeError("Python API enabled, but cannot load uhd module!") - print("Skipping test, Python API not installed.") - self.report_result("python_api_tester", 'status', 'Skipped') - return devtest_src_dir = os.getenv('_UHD_DEVTEST_SRC_DIR', '') multi_usrp_test_path = \ os.path.join(devtest_src_dir, 'multi_usrp_test.py') @@ -71,11 +52,4 @@ class uhd_python_api_test(uhd_test_case): 'status', 'Passed' if run_results['passed'] else 'Failed', ) - self.assertTrue( - run_results['passed'], - msg="Errors occurred during test python_api_test. " - "Check log file for details.\n" - "Run results:\n{r}".format( - r=yaml.dump(run_results, default_flow_style=False) - ) - ) + return run_results |