diff --git a/sonic-xcvrd/tests/test_xcvrd.py b/sonic-xcvrd/tests/test_xcvrd.py index 1f8b46d48..c42d3ddb7 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 cfd516be1..12f14c581 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -319,6 +319,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