From 910bea1a1d08a45d5accf69f99ffcc5c421d09e5 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 16 Oct 2024 09:37:50 +0200 Subject: [PATCH] ci: bypass import failure while checking test scripts we mock the missing packages in pytest_collectstart in plugin.py. but here the common_test_methods are imported by other scripts, which got executed earlier. --- tools/ci/python_packages/common_test_methods.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/ci/python_packages/common_test_methods.py b/tools/ci/python_packages/common_test_methods.py index 80392fbc27..fe5db2a9e7 100644 --- a/tools/ci/python_packages/common_test_methods.py +++ b/tools/ci/python_packages/common_test_methods.py @@ -1,12 +1,19 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - import logging import os import socket -from typing import Any, List +from typing import Any +from typing import List + +try: + import netifaces +except ImportError: + from unittest.mock import MagicMock + + netifaces = MagicMock() + logging.warning('netifaces is not installed. Please install it to get network interface information.') -import netifaces import yaml ENV_CONFIG_FILE_SEARCH = [