Speed up a few more tests by mocking time.sleep (#61186)

pull/61203/head
Matt Martz 5 years ago committed by GitHub
parent 0ff9978bc5
commit c81a1057e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,8 @@
import pytest import pytest
import unittest import unittest
from mock import patch
import ansible.modules.cloud.amazon.ec2_vpc_nat_gateway as ng import ansible.modules.cloud.amazon.ec2_vpc_nat_gateway as ng
@ -40,7 +42,8 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase):
self.assertTrue(success) self.assertTrue(success)
self.assertEqual(gws, should_return) 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) client = boto3.client('ec2', region_name=aws_region)
success, err_msg, gws = ( success, err_msg, gws = (
ng.wait_for_status( ng.wait_for_status(

@ -501,7 +501,8 @@ class TestMyModule(unittest.TestCase):
assert exc.value.args[0]['msg'] == msg assert exc.value.args[0]['msg'] == msg
mock_create.assert_called_with() 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 ''' ''' create flexcache '''
args = { args = {
'volume': 'volume_err', 'volume': 'volume_err',

@ -421,7 +421,8 @@ class TestLookupModuleWithoutPasslib(BaseTestLookupModule):
for result in results: for result in results:
self.assertEquals(result, u'a' * password.DEFAULT_LENGTH) 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 # pretend the lock file is here
password.os.path.exists = lambda x: True password.os.path.exists = lambda x: True
try: try:

Loading…
Cancel
Save