From 3e1317fd134de4d1a94a5fa92f485e0a0e3e4213 Mon Sep 17 00:00:00 2001 From: "hrushikesh.bhosale" Date: Wed, 9 Apr 2025 12:06:22 +0530 Subject: [PATCH] fix(ota): Fix the OTA pytest idf_path Due to ci/pytest-mark-formatter(branch) fix, while executing the main function from the pytest, it gives error for the incorrect idf_path. This commit ensure that, idf_path is fixed correctly. --- .../partitions_ota/pytest_partitions_ota.py | 7 ++-- .../simple_ota_example/pytest_simple_ota.py | 33 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/examples/system/ota/partitions_ota/pytest_partitions_ota.py b/examples/system/ota/partitions_ota/pytest_partitions_ota.py index acf574faa7..0b52615901 100644 --- a/examples/system/ota/partitions_ota/pytest_partitions_ota.py +++ b/examples/system/ota/partitions_ota/pytest_partitions_ota.py @@ -14,11 +14,14 @@ from pytest_embedded import Dut from pytest_embedded_idf.utils import idf_parametrize try: - from common_test_methods import get_env_config_variable, get_host_ip4_by_dest_ip + from common_test_methods import get_env_config_variable + from common_test_methods import get_host_ip4_by_dest_ip except ModuleNotFoundError: idf_path = os.environ['IDF_PATH'] + sys.path.append(idf_path + '/tools/ci') sys.path.insert(0, idf_path + '/tools/ci/python_packages') - from common_test_methods import get_env_config_variable, get_host_ip4_by_dest_ip + from common_test_methods import get_env_config_variable + from common_test_methods import get_host_ip4_by_dest_ip server_cert = ( '-----BEGIN CERTIFICATE-----\n' diff --git a/examples/system/ota/simple_ota_example/pytest_simple_ota.py b/examples/system/ota/simple_ota_example/pytest_simple_ota.py index d48080890b..e3ab7cd8f0 100644 --- a/examples/system/ota/simple_ota_example/pytest_simple_ota.py +++ b/examples/system/ota/simple_ota_example/pytest_simple_ota.py @@ -16,11 +16,14 @@ from pytest_embedded import Dut from pytest_embedded_idf.utils import idf_parametrize try: - from common_test_methods import get_env_config_variable, get_host_ip4_by_dest_ip + from common_test_methods import get_env_config_variable + from common_test_methods import get_host_ip4_by_dest_ip except ModuleNotFoundError: idf_path = os.environ['IDF_PATH'] + sys.path.append(idf_path + '/tools/ci') sys.path.insert(0, idf_path + '/tools/ci/python_packages') - from common_test_methods import get_env_config_variable, get_host_ip4_by_dest_ip + from common_test_methods import get_env_config_variable + from common_test_methods import get_host_ip4_by_dest_ip server_cert = ( '-----BEGIN CERTIFICATE-----\n' @@ -122,18 +125,20 @@ def start_tls1_3_server(ota_image_dir: str, server_port: int) -> subprocess.Pope key_file_handle.write(server_key) key_file_handle.close() - chunked_server = subprocess.Popen([ - 'openssl', - 's_server', - '-tls1_3', - '-WWW', - '-key', - key_file, - '-cert', - server_file, - '-port', - str(server_port), - ]) + chunked_server = subprocess.Popen( + [ + 'openssl', + 's_server', + '-tls1_3', + '-WWW', + '-key', + key_file, + '-cert', + server_file, + '-port', + str(server_port), + ] + ) return chunked_server