|
@@ -1231,6 +1231,16 @@ class TestBossComponents(unittest.TestCase):
|
|
|
'process': 'cat'
|
|
|
}
|
|
|
}
|
|
|
+ self._tmp_time = None
|
|
|
+ self._tmp_sleep = None
|
|
|
+
|
|
|
+ def tearDown(self):
|
|
|
+ if self._tmp_time is not None:
|
|
|
+ time.time = self._tmp_time
|
|
|
+ if self._tmp_sleep is not None:
|
|
|
+ time.sleep = self._tmp_sleep
|
|
|
+
|
|
|
+
|
|
|
|
|
|
def __unary_hook(self, param):
|
|
|
"""
|
|
@@ -1610,8 +1620,8 @@ class TestBossComponents(unittest.TestCase):
|
|
|
global tsec
|
|
|
attempts = 0
|
|
|
tsec = 0
|
|
|
- tmp_time = time.time
|
|
|
- tmp_sleep = time.sleep
|
|
|
+ self._tmp_time = time.time
|
|
|
+ self._tmp_sleep = time.sleep
|
|
|
def _my_time():
|
|
|
global attempts
|
|
|
global tsec
|
|
@@ -1633,8 +1643,7 @@ class TestBossComponents(unittest.TestCase):
|
|
|
# to happen inside start_msgq().
|
|
|
self.assertEqual(attempts, 13)
|
|
|
|
|
|
- time.time = tmp_time
|
|
|
- time.sleep = tmp_sleep
|
|
|
+ # time.time() and time.sleep() are restored during tearDown().
|
|
|
|
|
|
def test_start_cfgmgr(self):
|
|
|
'''Test that b10-cfgmgr is started.'''
|
|
@@ -1717,7 +1726,7 @@ class TestBossComponents(unittest.TestCase):
|
|
|
|
|
|
global attempts
|
|
|
attempts = 0
|
|
|
- tmp_sleep = time.sleep
|
|
|
+ self._tmp_sleep = time.sleep
|
|
|
def _my_sleep(nsec):
|
|
|
global attempts
|
|
|
attempts += 1
|
|
@@ -1736,7 +1745,7 @@ class TestBossComponents(unittest.TestCase):
|
|
|
# 2 seconds of attempts every 1 second should result in 2 attempts
|
|
|
self.assertEqual(attempts, 2)
|
|
|
|
|
|
- time.sleep = tmp_sleep
|
|
|
+ # time.sleep() is restored during tearDown().
|
|
|
|
|
|
def test_start_ccsession(self):
|
|
|
'''Test that CC session is started.'''
|