diff --git a/src/sonic_ax_impl/mibs/__init__.py b/src/sonic_ax_impl/mibs/__init__.py index 9dc0a986bf2f..0b0f8b48bbdb 100644 --- a/src/sonic_ax_impl/mibs/__init__.py +++ b/src/sonic_ax_impl/mibs/__init__.py @@ -2,7 +2,7 @@ import re import os -from swsssdk import SonicV2Connector +from swsscommon.swsscommon import SonicV2Connector from swsssdk import SonicDBConfig from swsssdk import port_util from swsssdk.port_util import get_index_from_str diff --git a/tests/mock_tables/dbconnector.py b/tests/mock_tables/dbconnector.py index 324feb42c8b4..27472bf8e6c6 100644 --- a/tests/mock_tables/dbconnector.py +++ b/tests/mock_tables/dbconnector.py @@ -4,9 +4,12 @@ import sys import mockredis -from swsssdk.interface import redis, DBInterface +import redis +import swsssdk from swsssdk import SonicV2Connector from swsssdk import SonicDBConfig +from swsssdk.interface import DBInterface +from swsscommon import swsscommon if sys.version_info >= (3, 0): @@ -91,7 +94,7 @@ def __init__(self, *args, **kwargs): # to identify the file path to load the db json files. namespace = kwargs.pop('namespace') db_name = kwargs.pop('db_name') - self.decode_responses = kwargs.pop('decode_responses') == True + self.decode_responses = kwargs.pop('decode_responses', False) == True fname = db_name.lower() + ".json" self.pubsub = MockPubSub() @@ -143,3 +146,9 @@ def keys(self, pattern='*'): mockredis.MockRedis.config_set = config_set redis.StrictRedis = SwssSyncClient SonicV2Connector.connect = connect_SonicV2Connector +swsscommon.SonicV2Connector = SonicV2Connector + +# pytest case collecting will import some module before monkey patch, so reload +from importlib import reload +import sonic_ax_impl.mibs +reload(sonic_ax_impl.mibs)