Stop time.sleep mocks in unit tests 33/58533/1
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Thu, 14 Jun 2018 13:14:27 +0000 (14:14 +0100)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Thu, 14 Jun 2018 13:29:00 +0000 (14:29 +0100)
tVpeApproxVnf and TestProxSocketHelper classes mock "time.sleep" in
the setUp method without deleting it at the end of the test execution.

JIRA: YARDSTICK-1243

Change-Id: Iff31d9c7b400ad8a47f37792aeb0d20328b9d9e1
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py

index c74a6cf..d9031cd 100644 (file)
@@ -293,7 +293,12 @@ no data length value
 class TestProxSocketHelper(unittest.TestCase):
 
     def setUp(self):
-        self.mock_time_sleep = mock.patch.object(time, 'sleep').start()
+        self._mock_time_sleep = mock.patch.object(time, 'sleep')
+        self.mock_time_sleep = self._mock_time_sleep.start()
+        self.addCleanup(self._stop_mocks)
+
+    def _stop_mocks(self):
+        self._mock_time_sleep.stop()
 
     @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.socket')
     def test___init__(self, mock_socket):
index 4fd51f0..73f91d1 100644 (file)
@@ -536,7 +536,12 @@ class TestVpeApproxVnf(unittest.TestCase):
     }
 
     def setUp(self):
-        self.mock_sleep = mock.patch.object(time, 'sleep').start()
+        self._mock_time_sleep = mock.patch.object(time, 'sleep')
+        self.mock_time_sleep = self._mock_time_sleep.start()
+        self.addCleanup(self._stop_mocks)
+
+    def _stop_mocks(self):
+        self._mock_time_sleep.stop()
 
     def test___init__(self):
         vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)