From afede0573231fe6f6746d6e271968f22af874b3e Mon Sep 17 00:00:00 2001 From: Paul Kronenwetter Date: Thu, 16 Jun 2022 18:35:49 -0400 Subject: [PATCH] Do a better job using environment variables. --- test/test_highsnr_stdio_C_P_datacx.py | 13 ++++++++----- test/test_highsnr_stdio_P_C_datacx.py | 13 ++++++++----- test/test_highsnr_stdio_P_P_datacx.py | 13 ++++++++----- test/test_highsnr_stdio_P_P_multi.py | 13 ++++++++----- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/test/test_highsnr_stdio_C_P_datacx.py b/test/test_highsnr_stdio_C_P_datacx.py index ac34b55d..fa5f4ba9 100644 --- a/test/test_highsnr_stdio_C_P_datacx.py +++ b/test/test_highsnr_stdio_C_P_datacx.py @@ -4,6 +4,7 @@ Tests a high signal-to-noise ratio path with codec2 data formats using codec2 to # pylint: disable=global-statement, invalid-name, unused-import +import contextlib import glob import multiprocessing import os @@ -13,14 +14,16 @@ import time import pytest -try: +BURSTS = 1 +FRAMESPERBURST = 1 +TESTFRAMES = 3 + +with contextlib.suppress(KeyError): BURSTS = int(os.environ["BURSTS"]) +with contextlib.suppress(KeyError): FRAMESPERBURST = int(os.environ["FRAMESPERBURST"]) +with contextlib.suppress(KeyError): TESTFRAMES = int(os.environ["TESTFRAMES"]) -except KeyError: - BURSTS = 1 - FRAMESPERBURST = 1 - TESTFRAMES = 3 # For some reason, sometimes, this test requires the current directory to be `test`. # Try to adapt dynamically. I still want to figure out why but as a workaround, diff --git a/test/test_highsnr_stdio_P_C_datacx.py b/test/test_highsnr_stdio_P_C_datacx.py index 47f6d533..ea5316df 100644 --- a/test/test_highsnr_stdio_P_C_datacx.py +++ b/test/test_highsnr_stdio_P_C_datacx.py @@ -4,6 +4,7 @@ Tests a high signal-to-noise ratio path with codec2 data formats using codec2 to # pylint: disable=global-statement, invalid-name, unused-import +import contextlib import glob import multiprocessing import os @@ -13,14 +14,16 @@ import time import pytest -try: +BURSTS = 1 +FRAMESPERBURST = 1 +TESTFRAMES = 3 + +with contextlib.suppress(KeyError): BURSTS = int(os.environ["BURSTS"]) +with contextlib.suppress(KeyError): FRAMESPERBURST = int(os.environ["FRAMESPERBURST"]) +with contextlib.suppress(KeyError): TESTFRAMES = int(os.environ["TESTFRAMES"]) -except KeyError: - BURSTS = 1 - FRAMESPERBURST = 1 - TESTFRAMES = 3 # For some reason, sometimes, this test requires the current directory to be `test`. # Try to adapt dynamically. I still want to figure out why but as a workaround, diff --git a/test/test_highsnr_stdio_P_P_datacx.py b/test/test_highsnr_stdio_P_P_datacx.py index 8975a6d6..634d5164 100644 --- a/test/test_highsnr_stdio_P_P_datacx.py +++ b/test/test_highsnr_stdio_P_P_datacx.py @@ -4,6 +4,7 @@ Tests a high signal-to-noise ratio path with codec2 data formats. # pylint: disable=global-statement, invalid-name, unused-import +import contextlib import multiprocessing import os import subprocess @@ -12,14 +13,16 @@ import time import pytest -try: +BURSTS = 1 +FRAMESPERBURST = 1 +TESTFRAMES = 3 + +with contextlib.suppress(KeyError): BURSTS = int(os.environ["BURSTS"]) +with contextlib.suppress(KeyError): FRAMESPERBURST = int(os.environ["FRAMESPERBURST"]) +with contextlib.suppress(KeyError): TESTFRAMES = int(os.environ["TESTFRAMES"]) -except KeyError: - BURSTS = 1 - FRAMESPERBURST = 1 - TESTFRAMES = 3 # For some reason, sometimes, this test requires the current directory to be `test`. # Try to adapt dynamically. I still want to figure out why but as a workaround, diff --git a/test/test_highsnr_stdio_P_P_multi.py b/test/test_highsnr_stdio_P_P_multi.py index cba9bb07..17f44781 100644 --- a/test/test_highsnr_stdio_P_P_multi.py +++ b/test/test_highsnr_stdio_P_P_multi.py @@ -4,6 +4,7 @@ Tests a high signal-to-noise ratio path with multiple codec2 data formats. # pylint: disable=global-statement, invalid-name, unused-import +import contextlib import multiprocessing import os import subprocess @@ -12,14 +13,16 @@ import time import pytest -try: +BURSTS = 1 +FRAMESPERBURST = 1 +TESTFRAMES = 3 + +with contextlib.suppress(KeyError): BURSTS = int(os.environ["BURSTS"]) +with contextlib.suppress(KeyError): FRAMESPERBURST = int(os.environ["FRAMESPERBURST"]) +with contextlib.suppress(KeyError): TESTFRAMES = int(os.environ["TESTFRAMES"]) -except KeyError: - BURSTS = 1 - FRAMESPERBURST = 1 - TESTFRAMES = 3 # For some reason, sometimes, this test requires the current directory to be `test`. # Try to adapt dynamically. I still want to figure out why but as a workaround,