diff --git a/tests/common/test_framework_detection.py b/tests/common/test_framework_detection.py index ac42e0fda1b..c3aea5b0272 100644 --- a/tests/common/test_framework_detection.py +++ b/tests/common/test_framework_detection.py @@ -11,12 +11,9 @@ import importlib import logging import re -import sys import unittest -from importlib import import_module from importlib.machinery import ModuleSpec from typing import List -from unittest import mock from unittest.mock import MagicMock import pytest @@ -35,7 +32,7 @@ def __init__(self, mocked_modules: List[str], hidden_modules: List[str]): def __call__(self, fullname, path=None, target=None): if fullname in self._hidden_modules: return None - elif fullname in self._mocked_modules: + if fullname in self._mocked_modules: return ModuleSpec(fullname, loader=MagicMock(), origin="foo/bar") return _REAL_FIND_SPEC(fullname, path, target) @@ -44,7 +41,7 @@ def __call__(self, fullname, path=None, target=None): def test_frameworks_detected(ref_available_frameworks: List[str], nncf_caplog, mocker): unavailable_frameworks = [fw for fw in SUPPORTED_FRAMEWORKS if fw not in ref_available_frameworks] failer = FailForModules(ref_available_frameworks, unavailable_frameworks) - with unittest.mock.patch("importlib.util.find_spec", wraps=failer) as mocked_fs: + with unittest.mock.patch("importlib.util.find_spec", wraps=failer): with nncf_caplog.at_level(logging.INFO): importlib.reload(nncf) matches = re.search(r"Supported frameworks detected: (.*)", nncf_caplog.text)