diff --git a/sonic-xcvrd/tests/test_xcvrd.py b/sonic-xcvrd/tests/test_xcvrd.py index 400b72fdc..4275eaf59 100644 --- a/sonic-xcvrd/tests/test_xcvrd.py +++ b/sonic-xcvrd/tests/test_xcvrd.py @@ -2908,6 +2908,15 @@ def test_wrapper_is_flat_memory(self, mock_chassis): mock_chassis.get_sfp = MagicMock(side_effect=NotImplementedError) assert not _wrapper_is_flat_memory(1) + @patch('xcvrd.xcvrd.platform_chassis') + def test_wrapper_is_flat_memory_no_xcvr_api(self, mock_chassis): + mock_object = MagicMock() + mock_object.get_xcvr_api = MagicMock(return_value=None) + mock_chassis.get_sfp = MagicMock(return_value=mock_object) + + from xcvrd.xcvrd import _wrapper_is_flat_memory + assert _wrapper_is_flat_memory(1) == True + def test_check_port_in_range(self): range_str = '1 - 32' physical_port = 1 diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index d69e5ce30..ff147422a 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -318,6 +318,8 @@ def _wrapper_is_flat_memory(physical_port): try: sfp = platform_chassis.get_sfp(physical_port) api = sfp.get_xcvr_api() + if not api: + return True return api.is_flat_memory() except NotImplementedError: pass