Speed up a few more tests by mocking time.sleep (#61186)
This commit is contained in:
parent
0ff9978bc5
commit
c81a1057e1
3 changed files with 8 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
|||
import pytest
|
||||
import unittest
|
||||
|
||||
from mock import patch
|
||||
|
||||
import ansible.modules.cloud.amazon.ec2_vpc_nat_gateway as ng
|
||||
|
||||
|
||||
|
@ -40,7 +42,8 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase):
|
|||
self.assertTrue(success)
|
||||
self.assertEqual(gws, should_return)
|
||||
|
||||
def test_wait_for_status_to_timeout(self):
|
||||
@patch('time.sleep')
|
||||
def test_wait_for_status_to_timeout(self, mock_sleep):
|
||||
client = boto3.client('ec2', region_name=aws_region)
|
||||
success, err_msg, gws = (
|
||||
ng.wait_for_status(
|
||||
|
|
|
@ -501,7 +501,8 @@ class TestMyModule(unittest.TestCase):
|
|||
assert exc.value.args[0]['msg'] == msg
|
||||
mock_create.assert_called_with()
|
||||
|
||||
def test_create_flexcache_time_out(self):
|
||||
@patch('time.sleep')
|
||||
def test_create_flexcache_time_out(self, mock_sleep):
|
||||
''' create flexcache '''
|
||||
args = {
|
||||
'volume': 'volume_err',
|
||||
|
|
|
@ -421,7 +421,8 @@ class TestLookupModuleWithoutPasslib(BaseTestLookupModule):
|
|||
for result in results:
|
||||
self.assertEquals(result, u'a' * password.DEFAULT_LENGTH)
|
||||
|
||||
def test_lock_been_held(self):
|
||||
@patch('time.sleep')
|
||||
def test_lock_been_held(self, mock_sleep):
|
||||
# pretend the lock file is here
|
||||
password.os.path.exists = lambda x: True
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue