From e6c786bd02e6a253fcf67dec895e7c24e940c788 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Fri, 18 Dec 2020 15:36:48 +0800 Subject: [PATCH] [xcvrd] Fix unit test issue with Python 3 (#135) Why I did this? xcvrd unit test failed when building it with python3: ``` 17:23:50 _____________________ ERROR collecting tests/test_xcvrd.py _____________________ 17:23:50 tests/test_xcvrd.py:36: in 17:23:50 class TestXcvrdScript(object): 17:23:50 tests/test_xcvrd.py:41: in TestXcvrdScript 17:23:50 @patch('xcvrd.xcvrd.logical_port_name_to_physical_port_list', MagicMock(return_value=[0])) 17:23:50 E NameError: name 'patch' is not defined ``` How I did this? import the package patch --- sonic-xcvrd/tests/test_xcvrd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic-xcvrd/tests/test_xcvrd.py b/sonic-xcvrd/tests/test_xcvrd.py index c9b3ffbb3e7a..724b01e7bae9 100644 --- a/sonic-xcvrd/tests/test_xcvrd.py +++ b/sonic-xcvrd/tests/test_xcvrd.py @@ -6,7 +6,7 @@ import unittest from imp import load_source if sys.version_info >= (3, 3): - from unittest.mock import MagicMock + from unittest.mock import MagicMock, patch else: from mock import MagicMock, patch