Replace TestCase.assertEquals with TestCase.assertEqual.

This commit is contained in:
Mads Jensen 2019-11-06 14:54:25 +01:00 committed by Matt Clay
parent a7ae0da6a4
commit 0f491c0289
40 changed files with 332 additions and 334 deletions

View file

@ -178,7 +178,7 @@ class TestCliSetupVaultSecrets(unittest.TestCase):
self.assertEqual(len(res), 2)
matches = vault.match_secrets(res, ['prompt1'])
self.assertIn('prompt1', [x[0] for x in matches])
self.assertEquals(len(matches), 1)
self.assertEqual(len(matches), 1)
@patch('ansible.cli.get_file_vault_secret')
@patch('ansible.cli.PromptVaultSecret')

View file

@ -459,7 +459,7 @@ class TestGalaxyInitSkeleton(unittest.TestCase, ValidRoleTests):
self.assertTrue(os.path.exists(os.path.join(self.role_dir, 'templates_extra', 'templates.txt')))
def test_skeleton_option(self):
self.assertEquals(self.role_skeleton_path, context.CLIARGS['role_skeleton'], msg='Skeleton path was not parsed properly from the command line')
self.assertEqual(self.role_skeleton_path, context.CLIARGS['role_skeleton'], msg='Skeleton path was not parsed properly from the command line')
@pytest.mark.parametrize('cli_args, expected', [

View file

@ -44,9 +44,9 @@ class YamlTestUtils(object):
dumper=AnsibleDumper)
# The gen 1 and gen 2 yaml strings
self.assertEquals(string_from_object_dump, string_from_object_dump_2)
self.assertEqual(string_from_object_dump, string_from_object_dump_2)
# the gen 1 (orig) and gen 2 py object
self.assertEquals(obj, obj_2)
self.assertEqual(obj, obj_2)
# again! gen 3... load strings into py objects
stream_3 = io.StringIO(string_from_object_dump_2)
@ -55,10 +55,10 @@ class YamlTestUtils(object):
string_from_object_dump_3 = self._dump_string(obj_3, dumper=AnsibleDumper)
self.assertEquals(obj, obj_3)
self.assertEqual(obj, obj_3)
# should be transitive, but...
self.assertEquals(obj_2, obj_3)
self.assertEquals(string_from_object_dump, string_from_object_dump_3)
self.assertEqual(obj_2, obj_3)
self.assertEqual(string_from_object_dump, string_from_object_dump_3)
def _old_dump_load_cycle(self, obj):
'''Dump the passed in object to yaml, load it back up, dump again, compare.'''

View file

@ -53,7 +53,7 @@ class TestHeuristicLogSanitize(unittest.TestCase):
return hostvars
def test_did_not_hide_too_much(self):
self.assertEquals(heuristic_log_sanitize(self.clean_data), self.clean_data)
self.assertEqual(heuristic_log_sanitize(self.clean_data), self.clean_data)
def test_hides_url_secrets(self):
url_output = heuristic_log_sanitize(self.url_data)

View file

@ -43,7 +43,7 @@ class TestReturnValues(unittest.TestCase):
def test_return_datastructure_name(self):
for data, expected in self.dataset:
self.assertEquals(frozenset(_return_datastructure_name(data)), expected)
self.assertEqual(frozenset(_return_datastructure_name(data)), expected)
def test_unknown_type(self):
self.assertRaises(TypeError, frozenset, _return_datastructure_name(object()))
@ -123,11 +123,11 @@ class TestRemoveValues(unittest.TestCase):
def test_no_removal(self):
for value, no_log_strings in self.dataset_no_remove:
self.assertEquals(remove_values(value, no_log_strings), value)
self.assertEqual(remove_values(value, no_log_strings), value)
def test_strings_to_remove(self):
for value, no_log_strings, expected in self.dataset_remove:
self.assertEquals(remove_values(value, no_log_strings), expected)
self.assertEqual(remove_values(value, no_log_strings), expected)
def test_unknown_type(self):
self.assertRaises(TypeError, remove_values, object(), frozenset())
@ -149,12 +149,12 @@ class TestRemoveValues(unittest.TestCase):
inner_list = actual_data_list
while inner_list:
if isinstance(inner_list, list):
self.assertEquals(len(inner_list), 1)
self.assertEqual(len(inner_list), 1)
else:
levels -= 1
break
inner_list = inner_list[0]
levels += 1
self.assertEquals(inner_list, self.OMIT)
self.assertEquals(levels, 10000)
self.assertEqual(inner_list, self.OMIT)
self.assertEqual(levels, 10000)

View file

@ -9,29 +9,29 @@ class ExponentialBackoffStrategyTestCase(unittest.TestCase):
def test_no_retries(self):
strategy = _exponential_backoff(retries=0)
result = list(strategy())
self.assertEquals(result, [], 'list should be empty')
self.assertEqual(result, [], 'list should be empty')
def test_exponential_backoff(self):
strategy = _exponential_backoff(retries=5, delay=1, backoff=2)
result = list(strategy())
self.assertEquals(result, [1, 2, 4, 8, 16])
self.assertEqual(result, [1, 2, 4, 8, 16])
def test_max_delay(self):
strategy = _exponential_backoff(retries=7, delay=1, backoff=2, max_delay=60)
result = list(strategy())
self.assertEquals(result, [1, 2, 4, 8, 16, 32, 60])
self.assertEqual(result, [1, 2, 4, 8, 16, 32, 60])
def test_max_delay_none(self):
strategy = _exponential_backoff(retries=7, delay=1, backoff=2, max_delay=None)
result = list(strategy())
self.assertEquals(result, [1, 2, 4, 8, 16, 32, 64])
self.assertEqual(result, [1, 2, 4, 8, 16, 32, 64])
class FullJitterBackoffStrategyTestCase(unittest.TestCase):
def test_no_retries(self):
strategy = _full_jitter_backoff(retries=0)
result = list(strategy())
self.assertEquals(result, [], 'list should be empty')
self.assertEqual(result, [], 'list should be empty')
def test_full_jitter(self):
retries = 5
@ -44,4 +44,4 @@ class FullJitterBackoffStrategyTestCase(unittest.TestCase):
retries=retries, delay=1, _random=random.Random(seed))
result = list(strategy())
self.assertEquals(result, expected)
self.assertEqual(result, expected)

View file

@ -324,7 +324,7 @@ class TestCollectorDepsWithFilter(unittest.TestCase):
expected = {'needed_fact': 'THE_NEEDED_FACT_VALUE',
'compound_fact': 'compound-THE_NEEDED_FACT_VALUE'}
self.assertEquals(expected, facts_dict)
self.assertEqual(expected, facts_dict)
def test_with_filter_on_compound_fact(self):
_mock_module = mock_module(gather_subset=['all', '!facter', '!ohai'],
@ -334,7 +334,7 @@ class TestCollectorDepsWithFilter(unittest.TestCase):
expected = {'compound_fact': 'compound-THE_NEEDED_FACT_VALUE'}
self.assertEquals(expected, facts_dict)
self.assertEqual(expected, facts_dict)
def test_with_filter_on_needed_fact(self):
_mock_module = mock_module(gather_subset=['all', '!facter', '!ohai'],
@ -344,7 +344,7 @@ class TestCollectorDepsWithFilter(unittest.TestCase):
expected = {'needed_fact': 'THE_NEEDED_FACT_VALUE'}
self.assertEquals(expected, facts_dict)
self.assertEqual(expected, facts_dict)
def test_with_filter_on_compound_gather_compound(self):
_mock_module = mock_module(gather_subset=['!all', '!any', 'compound_fact'],
@ -354,7 +354,7 @@ class TestCollectorDepsWithFilter(unittest.TestCase):
expected = {'compound_fact': 'compound-THE_NEEDED_FACT_VALUE'}
self.assertEquals(expected, facts_dict)
self.assertEqual(expected, facts_dict)
def test_with_filter_no_match(self):
_mock_module = mock_module(gather_subset=['all', '!facter', '!ohai'],
@ -363,7 +363,7 @@ class TestCollectorDepsWithFilter(unittest.TestCase):
facts_dict = self._collect(_mock_module)
expected = {}
self.assertEquals(expected, facts_dict)
self.assertEqual(expected, facts_dict)
def test_concat_collector(self):
_mock_module = mock_module(gather_subset=['all', '!facter', '!ohai'])

View file

@ -27,13 +27,13 @@ class ReplaceResourceDictTestCase(unittest.TestCase):
value = {
'selfLink': 'value'
}
self.assertEquals(replace_resource_dict(value, 'selfLink'), value['selfLink'])
self.assertEqual(replace_resource_dict(value, 'selfLink'), value['selfLink'])
def test_given_array(self):
value = {
'selfLink': 'value'
}
self.assertEquals(replace_resource_dict([value] * 3, 'selfLink'), [value['selfLink']] * 3)
self.assertEqual(replace_resource_dict([value] * 3, 'selfLink'), [value['selfLink']] * 3)
class NavigateHashTestCase(unittest.TestCase):
@ -41,7 +41,7 @@ class NavigateHashTestCase(unittest.TestCase):
value = {
'key': 'value'
}
self.assertEquals(navigate_hash(value, ['key']), value['key'])
self.assertEqual(navigate_hash(value, ['key']), value['key'])
def test_multilevel(self):
value = {
@ -49,14 +49,14 @@ class NavigateHashTestCase(unittest.TestCase):
'key2': 'value'
}
}
self.assertEquals(navigate_hash(value, ['key', 'key2']), value['key']['key2'])
self.assertEqual(navigate_hash(value, ['key', 'key2']), value['key']['key2'])
def test_default(self):
value = {
'key': 'value'
}
default = 'not found'
self.assertEquals(navigate_hash(value, ['key', 'key2'], default), default)
self.assertEqual(navigate_hash(value, ['key', 'key2'], default), default)
class RemoveNonesFromDictTestCase(unittest.TestCase):
@ -68,7 +68,7 @@ class RemoveNonesFromDictTestCase(unittest.TestCase):
value_correct = {
'good': 'value'
}
self.assertEquals(remove_nones_from_dict(value), value_correct)
self.assertEqual(remove_nones_from_dict(value), value_correct)
def test_remove_empty_arrays(self):
value = {
@ -78,7 +78,7 @@ class RemoveNonesFromDictTestCase(unittest.TestCase):
value_correct = {
'good': 'value'
}
self.assertEquals(remove_nones_from_dict(value), value_correct)
self.assertEqual(remove_nones_from_dict(value), value_correct)
def test_remove_empty_dicts(self):
value = {
@ -88,7 +88,7 @@ class RemoveNonesFromDictTestCase(unittest.TestCase):
value_correct = {
'good': 'value'
}
self.assertEquals(remove_nones_from_dict(value), value_correct)
self.assertEqual(remove_nones_from_dict(value), value_correct)
class GCPRequestDifferenceTestCase(unittest.TestCase):
@ -98,7 +98,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
'test': 'original'
}
request = GcpRequest(value1)
self.assertEquals(request, request)
self.assertEqual(request, request)
def test_simple_different(self):
value1 = {
@ -115,7 +115,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
request1 = GcpRequest(value1)
request2 = GcpRequest(value2)
self.assertNotEquals(request1, request2)
self.assertEquals(request1.difference(request2), difference)
self.assertEqual(request1.difference(request2), difference)
def test_nested_dictionaries_no_difference(self):
value1 = {
@ -128,7 +128,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
'test': 'original'
}
request = GcpRequest(value1)
self.assertEquals(request, request)
self.assertEqual(request, request)
def test_nested_dictionaries_with_difference(self):
value1 = {
@ -160,7 +160,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
request1 = GcpRequest(value1)
request2 = GcpRequest(value2)
self.assertNotEquals(request1, request2)
self.assertEquals(request1.difference(request2), difference)
self.assertEqual(request1.difference(request2), difference)
def test_arrays_strings_no_difference(self):
value1 = {
@ -170,7 +170,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
]
}
request = GcpRequest(value1)
self.assertEquals(request, request)
self.assertEqual(request, request)
def test_arrays_strings_with_difference(self):
value1 = {
@ -194,7 +194,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
request1 = GcpRequest(value1)
request2 = GcpRequest(value2)
self.assertNotEquals(request1, request2)
self.assertEquals(request1.difference(request2), difference)
self.assertEqual(request1.difference(request2), difference)
def test_arrays_dicts_with_no_difference(self):
value1 = {
@ -209,7 +209,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
]
}
request = GcpRequest(value1)
self.assertEquals(request, request)
self.assertEqual(request, request)
def test_arrays_dicts_with_difference(self):
value1 = {
@ -242,4 +242,4 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
request1 = GcpRequest(value1)
request2 = GcpRequest(value2)
self.assertNotEquals(request1, request2)
self.assertEquals(request1.difference(request2), difference)
self.assertEqual(request1.difference(request2), difference)

View file

@ -82,83 +82,83 @@ class GCPUtilsTestCase(unittest.TestCase):
# region, resource, entity, method
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/regions/us-east1/instanceGroupManagers/my-mig/recreateInstances'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('compute', actual['service'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('myproject', actual['project'])
self.assertEquals('us-east1', actual['region'])
self.assertEquals('instanceGroupManagers', actual['resource_name'])
self.assertEquals('my-mig', actual['entity_name'])
self.assertEquals('recreateInstances', actual['method_name'])
self.assertEqual('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('myproject', actual['project'])
self.assertEqual('us-east1', actual['region'])
self.assertEqual('instanceGroupManagers', actual['resource_name'])
self.assertEqual('my-mig', actual['entity_name'])
self.assertEqual('recreateInstances', actual['method_name'])
# zone, resource, entity, method
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/zones/us-east1-c/instanceGroupManagers/my-mig/recreateInstances'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('compute', actual['service'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('myproject', actual['project'])
self.assertEquals('us-east1-c', actual['zone'])
self.assertEquals('instanceGroupManagers', actual['resource_name'])
self.assertEquals('my-mig', actual['entity_name'])
self.assertEquals('recreateInstances', actual['method_name'])
self.assertEqual('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('myproject', actual['project'])
self.assertEqual('us-east1-c', actual['zone'])
self.assertEqual('instanceGroupManagers', actual['resource_name'])
self.assertEqual('my-mig', actual['entity_name'])
self.assertEqual('recreateInstances', actual['method_name'])
# global, resource
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('compute', actual['service'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('myproject', actual['project'])
self.assertEqual('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('myproject', actual['project'])
self.assertTrue('global' in actual)
self.assertTrue(actual['global'])
self.assertEquals('urlMaps', actual['resource_name'])
self.assertEqual('urlMaps', actual['resource_name'])
# global, resource, entity
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/my-url-map'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('myproject', actual['project'])
self.assertEqual('myproject', actual['project'])
self.assertTrue('global' in actual)
self.assertTrue(actual['global'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('compute', actual['service'])
# global URL, resource, entity, method_name
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/global/backendServices/mybackendservice/getHealth'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('compute', actual['service'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('myproject', actual['project'])
self.assertEqual('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('myproject', actual['project'])
self.assertTrue('global' in actual)
self.assertTrue(actual['global'])
self.assertEquals('backendServices', actual['resource_name'])
self.assertEquals('mybackendservice', actual['entity_name'])
self.assertEquals('getHealth', actual['method_name'])
self.assertEqual('backendServices', actual['resource_name'])
self.assertEqual('mybackendservice', actual['entity_name'])
self.assertEqual('getHealth', actual['method_name'])
# no location in URL
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/targetHttpProxies/mytargetproxy/setUrlMap'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('compute', actual['service'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('myproject', actual['project'])
self.assertEqual('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('myproject', actual['project'])
self.assertFalse('global' in actual)
self.assertEquals('targetHttpProxies', actual['resource_name'])
self.assertEquals('mytargetproxy', actual['entity_name'])
self.assertEquals('setUrlMap', actual['method_name'])
self.assertEqual('targetHttpProxies', actual['resource_name'])
self.assertEqual('mytargetproxy', actual['entity_name'])
self.assertEqual('setUrlMap', actual['method_name'])
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/targetHttpProxies/mytargetproxy'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('compute', actual['service'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('myproject', actual['project'])
self.assertEqual('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('myproject', actual['project'])
self.assertFalse('global' in actual)
self.assertEquals('targetHttpProxies', actual['resource_name'])
self.assertEquals('mytargetproxy', actual['entity_name'])
self.assertEqual('targetHttpProxies', actual['resource_name'])
self.assertEqual('mytargetproxy', actual['entity_name'])
input_url = 'https://www.googleapis.com/compute/v1/projects/myproject/targetHttpProxies'
actual = GCPUtils.parse_gcp_url(input_url)
self.assertEquals('compute', actual['service'])
self.assertEquals('v1', actual['api_version'])
self.assertEquals('myproject', actual['project'])
self.assertEqual('compute', actual['service'])
self.assertEqual('v1', actual['api_version'])
self.assertEqual('myproject', actual['project'])
self.assertFalse('global' in actual)
self.assertEquals('targetHttpProxies', actual['resource_name'])
self.assertEqual('targetHttpProxies', actual['resource_name'])
# test exceptions
no_projects_input_url = 'https://www.googleapis.com/compute/v1/not-projects/myproject/global/backendServices/mybackendservice/getHealth'
@ -368,4 +368,4 @@ class GCPUtilsTestCase(unittest.TestCase):
'requestPath': '/'}
actual = GCPUtils.filter_gcp_fields(input_data)
self.assertEquals(expected, actual)
self.assertEqual(expected, actual)

View file

@ -15,10 +15,10 @@ class HwcUtilsTestCase(unittest.TestCase):
}
}
self.assertEquals(navigate_value(value, ["foo", "quiet", "tree"]),
"test")
self.assertEqual(navigate_value(value, ["foo", "quiet", "tree"]),
"test")
self.assertEquals(
self.assertEqual(
navigate_value(value, ["foo", "quiet", "trees"],
{"foo.quiet.trees": 1}),
1)

View file

@ -55,29 +55,29 @@ class TestAnsibleModuleExitJson(unittest.TestCase):
def test_just_json(self):
for i in self.all_inputs:
filtered, warnings = _filter_non_json_lines(i)
self.assertEquals(filtered, i)
self.assertEquals(warnings, [])
self.assertEqual(filtered, i)
self.assertEqual(warnings, [])
def test_leading_junk(self):
for i in self.all_inputs:
for j in self.junk:
filtered, warnings = _filter_non_json_lines(j + "\n" + i)
self.assertEquals(filtered, i)
self.assertEquals(warnings, [])
self.assertEqual(filtered, i)
self.assertEqual(warnings, [])
def test_trailing_junk(self):
for i in self.all_inputs:
for j in self.junk:
filtered, warnings = _filter_non_json_lines(i + "\n" + j)
self.assertEquals(filtered, i)
self.assertEquals(warnings, [u"Module invocation had junk after the JSON data: %s" % j.strip()])
self.assertEqual(filtered, i)
self.assertEqual(warnings, [u"Module invocation had junk after the JSON data: %s" % j.strip()])
def test_leading_and_trailing_junk(self):
for i in self.all_inputs:
for j in self.junk:
filtered, warnings = _filter_non_json_lines("\n".join([j, i, j]))
self.assertEquals(filtered, i)
self.assertEquals(warnings, [u"Module invocation had junk after the JSON data: %s" % j.strip()])
self.assertEqual(filtered, i)
self.assertEqual(warnings, [u"Module invocation had junk after the JSON data: %s" % j.strip()])
def test_unparsable_filter_non_json_lines(self):
for i in self.unparsable_cases:

View file

@ -367,8 +367,8 @@ class TestJsonRpc(unittest.TestCase):
]
open_url_mock.side_effect = lambda *args, **kwargs: mock_call(calls, *args, **kwargs)
client = nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False)
self.assertEquals(True, client.exists('/exists'))
self.assertEquals(False, client.exists('/not-exists'))
self.assertEqual(True, client.exists('/exists'))
self.assertEqual(False, client.exists('/not-exists'))
self.assertEqual(0, len(calls))
@ -380,7 +380,7 @@ class TestJsonRpc(unittest.TestCase):
]
open_url_mock.side_effect = lambda *args, **kwargs: mock_call(calls, *args, **kwargs)
client = nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False)
self.assertEquals(False, client.exists('/list{missing-parent}/list{child}'))
self.assertEqual(False, client.exists('/list{missing-parent}/list{child}'))
self.assertEqual(0, len(calls))
@ -404,11 +404,11 @@ class TestValueBuilder(unittest.TestCase):
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False))
vb.build(parent, None, 'ansible-nso:id-two', schema)
values = list(vb.values)
self.assertEquals(1, len(values))
self.assertEqual(1, len(values))
value = values[0]
self.assertEquals(parent, value.path)
self.assertEquals('set', value.state)
self.assertEquals('an:id-two', value.value)
self.assertEqual(parent, value.path)
self.assertEqual('set', value.state)
self.assertEqual('an:id-two', value.value)
self.assertEqual(0, len(calls))
@ -431,11 +431,11 @@ class TestValueBuilder(unittest.TestCase):
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False))
vb.build(parent, 'id-name-value', [{'name': 'ansible-nso:id-one', 'value': '1'}], schema)
values = list(vb.values)
self.assertEquals(1, len(values))
self.assertEqual(1, len(values))
value = values[0]
self.assertEquals('{0}/id-name-value{{an:id-one}}/value'.format(parent), value.path)
self.assertEquals('set', value.state)
self.assertEquals('1', value.value)
self.assertEqual('{0}/id-name-value{{an:id-one}}/value'.format(parent), value.path)
self.assertEqual('set', value.state)
self.assertEqual('1', value.value)
self.assertEqual(0, len(calls))
@ -459,16 +459,16 @@ class TestValueBuilder(unittest.TestCase):
vb.build(parent, None, [{'name': 'direct', 'direct-child': 'direct-value'},
{'name': 'nested', 'nested-child': 'nested-value'}], schema)
values = list(vb.values)
self.assertEquals(2, len(values))
self.assertEqual(2, len(values))
value = values[0]
self.assertEquals('{0}{{direct}}/direct-child'.format(parent), value.path)
self.assertEquals('set', value.state)
self.assertEquals('direct-value', value.value)
self.assertEqual('{0}{{direct}}/direct-child'.format(parent), value.path)
self.assertEqual('set', value.state)
self.assertEqual('direct-value', value.value)
value = values[1]
self.assertEquals('{0}{{nested}}/nested-child'.format(parent), value.path)
self.assertEquals('set', value.state)
self.assertEquals('nested-value', value.value)
self.assertEqual('{0}{{nested}}/nested-child'.format(parent), value.path)
self.assertEqual('set', value.state)
self.assertEqual('nested-value', value.value)
self.assertEqual(0, len(calls))
@ -489,10 +489,10 @@ class TestValueBuilder(unittest.TestCase):
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False))
vb.build(parent, None, {'device-list': ['one', 'two']}, schema)
values = list(vb.values)
self.assertEquals(1, len(values))
self.assertEqual(1, len(values))
value = values[0]
self.assertEquals('{0}/device-list'.format(parent), value.path)
self.assertEquals(['one', 'two'], value.value)
self.assertEqual('{0}/device-list'.format(parent), value.path)
self.assertEqual(['one', 'two'], value.value)
self.assertEqual(0, len(calls))
@ -513,16 +513,16 @@ class TestValueBuilder(unittest.TestCase):
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False))
vb.build(parent, None, {'device-list': ['one', 'two']}, schema)
values = list(vb.values)
self.assertEquals(3, len(values))
self.assertEqual(3, len(values))
value = values[0]
self.assertEquals('{0}/device-list'.format(parent), value.path)
self.assertEquals(nso.State.ABSENT, value.state)
self.assertEqual('{0}/device-list'.format(parent), value.path)
self.assertEqual(nso.State.ABSENT, value.state)
value = values[1]
self.assertEquals('{0}/device-list{{one}}'.format(parent), value.path)
self.assertEquals(nso.State.PRESENT, value.state)
self.assertEqual('{0}/device-list{{one}}'.format(parent), value.path)
self.assertEqual(nso.State.PRESENT, value.state)
value = values[2]
self.assertEquals('{0}/device-list{{two}}'.format(parent), value.path)
self.assertEquals(nso.State.PRESENT, value.state)
self.assertEqual('{0}/device-list{{two}}'.format(parent), value.path)
self.assertEqual(nso.State.PRESENT, value.state)
self.assertEqual(0, len(calls))
@ -549,16 +549,16 @@ class TestValueBuilder(unittest.TestCase):
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False))
vb.build(parent, None, values, schema)
values = list(vb.values)
self.assertEquals(3, len(values))
self.assertEqual(3, len(values))
value = values[0]
self.assertEquals('{0}/c'.format(parent), value.path)
self.assertEquals('3', value.value)
self.assertEqual('{0}/c'.format(parent), value.path)
self.assertEqual('3', value.value)
value = values[1]
self.assertEquals('{0}/a'.format(parent), value.path)
self.assertEquals('1', value.value)
self.assertEqual('{0}/a'.format(parent), value.path)
self.assertEqual('1', value.value)
value = values[2]
self.assertEquals('{0}/b'.format(parent), value.path)
self.assertEquals('2', value.value)
self.assertEqual('{0}/b'.format(parent), value.path)
self.assertEqual('2', value.value)
self.assertEqual(0, len(calls))
@ -584,13 +584,13 @@ class TestValueBuilder(unittest.TestCase):
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10, False))
vb.build(parent, None, values, schema)
values = list(vb.values)
self.assertEquals(2, len(values))
self.assertEqual(2, len(values))
value = values[0]
self.assertEquals('{0}/a'.format(parent), value.path)
self.assertEquals('1', value.value)
self.assertEqual('{0}/a'.format(parent), value.path)
self.assertEqual('1', value.value)
value = values[1]
self.assertEquals('{0}/b'.format(parent), value.path)
self.assertEquals('2', value.value)
self.assertEqual('{0}/b'.format(parent), value.path)
self.assertEqual('2', value.value)
self.assertEqual(0, len(calls))
@ -624,7 +624,7 @@ class TestValueSort(unittest.TestCase):
result = [v.path for v in nso.ValueBuilder.sort_values(values)]
self.assertEquals(['/test/list{entry}', '/test/entry', '/test/list{entry}/description'], result)
self.assertEqual(['/test/list{entry}', '/test/entry', '/test/list{entry}/description'], result)
def test_sort_break_direct_cycle(self):
values = [
@ -635,7 +635,7 @@ class TestValueSort(unittest.TestCase):
result = [v.path for v in nso.ValueBuilder.sort_values(values)]
self.assertEquals(['/test/a', '/test/b', '/test/c'], result)
self.assertEqual(['/test/a', '/test/b', '/test/c'], result)
def test_sort_break_indirect_cycle(self):
values = [
@ -646,7 +646,7 @@ class TestValueSort(unittest.TestCase):
result = [v.path for v in nso.ValueBuilder.sort_values(values)]
self.assertEquals(['/test/a', '/test/c', '/test/b'], result)
self.assertEqual(['/test/a', '/test/c', '/test/b'], result)
def test_sort_depend_on_self(self):
values = [

View file

@ -9,7 +9,7 @@ class PagerDutyTest(unittest.TestCase):
self.pd = pagerduty.PagerDutyRequest(module=pagerduty, name='name', user='user', token='token')
def _assert_ongoing_maintenance_windows(self, module, url, headers):
self.assertEquals('https://api.pagerduty.com/maintenance_windows?filter=ongoing', url)
self.assertEqual('https://api.pagerduty.com/maintenance_windows?filter=ongoing', url)
return object(), {'status': 200}
def _assert_ongoing_window_with_v1_compatible_header(self, module, url, headers, data=None, method=None):
@ -21,11 +21,11 @@ class PagerDutyTest(unittest.TestCase):
return object(), {'status': 200}
def _assert_create_a_maintenance_window_url(self, module, url, headers, data=None, method=None):
self.assertEquals('https://api.pagerduty.com/maintenance_windows', url)
self.assertEqual('https://api.pagerduty.com/maintenance_windows', url)
return object(), {'status': 201}
def _assert_create_a_maintenance_window_http_method(self, module, url, headers, data=None, method=None):
self.assertEquals('POST', method)
self.assertEqual('POST', method)
return object(), {'status': 201}
def _assert_create_a_maintenance_window_from_header(self, module, url, headers, data=None, method=None):
@ -56,7 +56,7 @@ class PagerDutyTest(unittest.TestCase):
payload = json.loads(data)
window_data = payload['maintenance_window']
services = window_data['services']
self.assertEquals(
self.assertEqual(
[{'id': 'service_id', 'type': 'service_reference'}],
services
)
@ -67,7 +67,7 @@ class PagerDutyTest(unittest.TestCase):
window_data = payload['maintenance_window']
services = window_data['services']
print(services)
self.assertEquals(
self.assertEqual(
[
{'id': 'service_id_1', 'type': 'service_reference'},
{'id': 'service_id_2', 'type': 'service_reference'},
@ -78,7 +78,7 @@ class PagerDutyTest(unittest.TestCase):
return object(), {'status': 201}
def _assert_absent_maintenance_window_url(self, module, url, headers, method=None):
self.assertEquals('https://api.pagerduty.com/maintenance_windows/window_id', url)
self.assertEqual('https://api.pagerduty.com/maintenance_windows/window_id', url)
return object(), {'status': 204}
def _assert_absent_window_with_v1_compatible_header(self, module, url, headers, method=None):

View file

@ -75,7 +75,7 @@ class TestCloudEngineLacpModule(TestCloudEngineModule):
select='Speed',
state='present'))
result = self.execute_module(changed=True)
self.assertEquals(sorted(result['updates']), sorted(update))
self.assertEqual(sorted(result['updates']), sorted(update))
def test_lacp_eturnk_absent(self):
xml_existing = load_fixture('ce_lacp', 'ce_lacp_10.txt')
@ -112,7 +112,7 @@ class TestCloudEngineLacpModule(TestCloudEngineModule):
state='absent'
))
result = self.execute_module(changed=True)
self.assertEquals(sorted(result['updates']), sorted(default_values))
self.assertEqual(sorted(result['updates']), sorted(default_values))
def test_lacp_global_present(self):
xml_existing = load_fixture('ce_lacp', 'ce_lacp_10.txt')
@ -121,7 +121,7 @@ class TestCloudEngineLacpModule(TestCloudEngineModule):
set_module_args(dict(global_priority=32769,
state='present'))
result = self.execute_module(changed=True)
self.assertEquals(result['updates'], ['lacp priority 32769'])
self.assertEqual(result['updates'], ['lacp priority 32769'])
def test_lacp_global_absent(self):
xml_existing = load_fixture('ce_lacp', 'ce_lacp_11.txt')
@ -131,4 +131,4 @@ class TestCloudEngineLacpModule(TestCloudEngineModule):
state='absent'))
result = self.execute_module(changed=True)
# excpect: lacp priority is set to default value(32768)
self.assertEquals(result['updates'], ['lacp priority 32768'])
self.assertEqual(result['updates'], ['lacp priority 32768'])

View file

@ -79,7 +79,7 @@ class TestCloudEngineLacpModule(TestCloudEngineModule):
bind_name='bind-name')
)
result = self.execute_module(changed=True)
self.assertEquals(sorted(result['updates']), sorted(update))
self.assertEqual(sorted(result['updates']), sorted(update))
def test_lacp_sys_parameter_present(self):
update = ['lldp enable',
@ -110,4 +110,4 @@ class TestCloudEngineLacpModule(TestCloudEngineModule):
bind_name='bind-name')
)
result = self.execute_module(changed=True)
self.assertEquals(sorted(result['updates']), sorted(update))
self.assertEqual(sorted(result['updates']), sorted(update))

View file

@ -99,4 +99,4 @@ class TestCloudEngineLacpModule(TestCloudEngineModule):
)
set_module_args(config)
result = self.execute_module(changed=True)
self.assertEquals(sorted(result['updates']), sorted(updates))
self.assertEqual(sorted(result['updates']), sorted(updates))

View file

@ -67,10 +67,10 @@ class TestCnosFacts(TestCnosModule):
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('ip10-241-107-39', ansible_facts['ansible_net_hostname'])
self.assertEqual('ip10-241-107-39', ansible_facts['ansible_net_hostname'])
self.assertIn('Ethernet1/1', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(3985.8046875, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(3070.40234375, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual(3985.8046875, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(3070.40234375, ansible_facts['ansible_net_memfree_mb'])
def test_cnos_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})
@ -78,5 +78,5 @@ class TestCnosFacts(TestCnosModule):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('ip10-241-107-39', ansible_facts['ansible_net_hostname'])
self.assertEqual('ip10-241-107-39', ansible_facts['ansible_net_hostname'])
self.assertIn('ansible_net_config', ansible_facts)

View file

@ -74,10 +74,10 @@ class TestDellos10Facts(TestDellos10Module):
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('os10', ansible_facts['ansible_net_hostname'])
self.assertEqual('os10', ansible_facts['ansible_net_hostname'])
self.assertIn('ethernet1/1/8', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(7936, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(5693, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual(7936, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(5693, ansible_facts['ansible_net_memfree_mb'])
def test_dellos10_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})
@ -85,7 +85,7 @@ class TestDellos10Facts(TestDellos10Module):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('os10', ansible_facts['ansible_net_hostname'])
self.assertEqual('os10', ansible_facts['ansible_net_hostname'])
self.assertIn('ansible_net_config', ansible_facts)
def test_dellos10_facts_gather_subset_hardware(self):
@ -94,9 +94,9 @@ class TestDellos10Facts(TestDellos10Module):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('x86_64', ansible_facts['ansible_net_cpu_arch'])
self.assertEquals(7936, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(5693, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual('x86_64', ansible_facts['ansible_net_cpu_arch'])
self.assertEqual(7936, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(5693, ansible_facts['ansible_net_memfree_mb'])
def test_dellos10_facts_gather_subset_interfaces(self):
set_module_args({'gather_subset': 'interfaces'})
@ -105,6 +105,6 @@ class TestDellos10Facts(TestDellos10Module):
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertIn('ethernet1/1/8', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(sorted(['mgmt1/1/1', 'ethernet1/1/4', 'ethernet1/1/2', 'ethernet1/1/3', 'ethernet1/1/1']),
sorted(list(ansible_facts['ansible_net_neighbors'].keys())))
self.assertEqual(sorted(['mgmt1/1/1', 'ethernet1/1/4', 'ethernet1/1/2', 'ethernet1/1/3', 'ethernet1/1/1']),
sorted(list(ansible_facts['ansible_net_neighbors'].keys())))
self.assertIn('ansible_net_interfaces', ansible_facts)

View file

@ -71,10 +71,10 @@ class TestDellos6Facts(TestDellos6Module):
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('"dellos6_sw1"', ansible_facts['ansible_net_hostname'])
self.assertEqual('"dellos6_sw1"', ansible_facts['ansible_net_hostname'])
self.assertIn('Te1/0/1', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(1682, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(623, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual(1682, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(623, ansible_facts['ansible_net_memfree_mb'])
def test_dellos6_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})
@ -82,7 +82,7 @@ class TestDellos6Facts(TestDellos6Module):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('"dellos6_sw1"', ansible_facts['ansible_net_hostname'])
self.assertEqual('"dellos6_sw1"', ansible_facts['ansible_net_hostname'])
self.assertIn('ansible_net_config', ansible_facts)
def test_dellos6_facts_gather_subset_hardware(self):
@ -91,8 +91,8 @@ class TestDellos6Facts(TestDellos6Module):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertEquals(1682, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(623, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual(1682, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(623, ansible_facts['ansible_net_memfree_mb'])
def test_dellos6_facts_gather_subset_interfaces(self):
set_module_args({'gather_subset': 'interfaces'})
@ -101,5 +101,5 @@ class TestDellos6Facts(TestDellos6Module):
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertIn('Te1/0/1', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(['Te1/0/5'], list(ansible_facts['ansible_net_neighbors'].keys()))
self.assertEqual(['Te1/0/5'], list(ansible_facts['ansible_net_neighbors'].keys()))
self.assertIn('ansible_net_interfaces', ansible_facts)

View file

@ -71,10 +71,10 @@ class TestDellos9Facts(TestDellos9Module):
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('dellos9_sw1', ansible_facts['ansible_net_hostname'])
self.assertEqual('dellos9_sw1', ansible_facts['ansible_net_hostname'])
self.assertIn('fortyGigE 0/24', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(3128820, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(3125722, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual(3128820, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(3125722, ansible_facts['ansible_net_memfree_mb'])
def test_dellos9_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})
@ -82,7 +82,7 @@ class TestDellos9Facts(TestDellos9Module):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('dellos9_sw1', ansible_facts['ansible_net_hostname'])
self.assertEqual('dellos9_sw1', ansible_facts['ansible_net_hostname'])
self.assertIn('ansible_net_config', ansible_facts)
def test_dellos9_facts_gather_subset_hardware(self):
@ -91,9 +91,9 @@ class TestDellos9Facts(TestDellos9Module):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertEquals(['flash', 'fcmfs', 'nfsmount', 'ftp', 'tftp', 'scp', 'http', 'https'], ansible_facts['ansible_net_filesystems'])
self.assertEquals(3128820, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(3125722, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual(['flash', 'fcmfs', 'nfsmount', 'ftp', 'tftp', 'scp', 'http', 'https'], ansible_facts['ansible_net_filesystems'])
self.assertEqual(3128820, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(3125722, ansible_facts['ansible_net_memfree_mb'])
def test_dellos9_facts_gather_subset_interfaces(self):
set_module_args({'gather_subset': 'interfaces'})
@ -102,5 +102,5 @@ class TestDellos9Facts(TestDellos9Module):
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertIn('fortyGigE 0/24', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(['Ma 0/0'], list(ansible_facts['ansible_net_neighbors'].keys()))
self.assertEqual(['Ma 0/0'], list(ansible_facts['ansible_net_neighbors'].keys()))
self.assertIn('ansible_net_interfaces', ansible_facts)

View file

@ -67,10 +67,10 @@ class TestEnosFacts(TestEnosModule):
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('test1', ansible_facts['ansible_net_hostname'])
self.assertEqual('test1', ansible_facts['ansible_net_hostname'])
self.assertIn('MGT', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals(3992.75390625, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(3383.109375, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual(3992.75390625, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(3383.109375, ansible_facts['ansible_net_memfree_mb'])
def test_enos_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})
@ -78,5 +78,5 @@ class TestEnosFacts(TestEnosModule):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('test1', ansible_facts['ansible_net_hostname'])
self.assertEqual('test1', ansible_facts['ansible_net_hostname'])
self.assertIn('ansible_net_config', ansible_facts)

View file

@ -87,11 +87,11 @@ class TestIosxrFacts(TestIosxrModule):
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('iosxr01', ansible_facts['ansible_net_hostname'])
self.assertEquals(['disk0:', 'flash0:'], ansible_facts['ansible_net_filesystems'])
self.assertEqual('iosxr01', ansible_facts['ansible_net_hostname'])
self.assertEqual(['disk0:', 'flash0:'], ansible_facts['ansible_net_filesystems'])
self.assertIn('GigabitEthernet0/0/0/0', ansible_facts['ansible_net_interfaces'].keys())
self.assertEquals('3095', ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals('1499', ansible_facts['ansible_net_memfree_mb'])
self.assertEqual('3095', ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual('1499', ansible_facts['ansible_net_memfree_mb'])
def test_iosxr_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})
@ -99,5 +99,5 @@ class TestIosxrFacts(TestIosxrModule):
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
self.assertEquals('iosxr01', ansible_facts['ansible_net_hostname'])
self.assertEqual('iosxr01', ansible_facts['ansible_net_hostname'])
self.assertIn('ansible_net_config', ansible_facts)

View file

@ -66,17 +66,17 @@ class TestIronwareFacts(TestIronwareModule):
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEquals(['/flash/'], ansible_facts['ansible_net_filesystems'])
self.assertEqual(['/flash/'], ansible_facts['ansible_net_filesystems'])
self.assertIn('1/1', ansible_facts['ansible_net_interfaces'].keys())
self.assertIn('10.69.1.6', ansible_facts['ansible_net_all_ipv4_addresses'])
self.assertIn('2001:db8::1', ansible_facts['ansible_net_all_ipv6_addresses'])
self.assertIn('ansible_net_neighbors', ansible_facts)
self.assertIn('1/2', ansible_facts['ansible_net_neighbors'].keys())
self.assertEquals(4096, ansible_facts['ansible_net_memtotal_mb'])
self.assertEquals(3630, ansible_facts['ansible_net_memfree_mb'])
self.assertEquals('5.8.0fT163', ansible_facts['ansible_net_version'])
self.assertEquals('MLXe 4-slot Chassis', ansible_facts['ansible_net_model'])
self.assertEquals('BGD2503J01F', ansible_facts['ansible_net_serialnum'])
self.assertEqual(4096, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(3630, ansible_facts['ansible_net_memfree_mb'])
self.assertEqual('5.8.0fT163', ansible_facts['ansible_net_version'])
self.assertEqual('MLXe 4-slot Chassis', ansible_facts['ansible_net_model'])
self.assertEqual('BGD2503J01F', ansible_facts['ansible_net_serialnum'])
def test_ironware_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})

View file

@ -907,7 +907,7 @@ class TestWorkflowModule(unittest.TestCase):
]
}
result = iap_start_workflow.start_workflow(module)
self.assertEquals(result, return_response)
self.assertEqual(result, return_response)
if __name__ == '__main__':

View file

@ -71,8 +71,8 @@ class AlertsTest(ModuleTestCase):
# Expecting an update
with mock.patch(self.REQ_FUNC, return_value=(200, expected)) as req:
actual = alerts.get_configuration()
self.assertEquals(expected, actual)
self.assertEquals(req.call_count, 1)
self.assertEqual(expected, actual)
self.assertEqual(req.call_count, 1)
def test_update_configuration(self):
"""Validate updating the configuration"""

View file

@ -55,7 +55,7 @@ class AsupTest(ModuleTestCase):
with mock.patch(self.REQ_FUNC, return_value=(200, expected)):
config = asup.get_configuration()
self.assertEquals(config, expected)
self.assertEqual(config, expected)
def test_update_configuration(self):
"""Validate retrieving the ASUP configuration"""
@ -149,9 +149,9 @@ class AsupTest(ModuleTestCase):
asup = Asup()
self.assertTrue(asup.asup)
self.assertEquals(asup.days, ["sunday", "monday", "tuesday"]),
self.assertEquals(asup.start, 1200)
self.assertEquals(asup.end, 1439)
self.assertEqual(asup.days, ["sunday", "monday", "tuesday"]),
self.assertEqual(asup.start, 1200)
self.assertEqual(asup.end, 1439)
def test_init_schedule_invalid(self):
"""Validate updating ASUP with invalid schedule fails test."""

View file

@ -452,4 +452,4 @@ class FactsTest(ModuleTestCase):
facts.is_embedded = lambda: True
with mock.patch(self.GET_CONTROLLERS_FUNC, return_value={"070000000000000000000001": "A", "070000000000000000000002": "B"}):
with mock.patch(self.REQUEST_FUNC, side_effect=[(200, self.GRAPH_RESPONSE), (200, self.WORKLOAD_RESPONSE)]):
self.assertEquals(facts.get_array_facts(), self.EXPECTED_GET_ARRAY_FACTS)
self.assertEqual(facts.get_array_facts(), self.EXPECTED_GET_ARRAY_FACTS)

View file

@ -46,7 +46,7 @@ class GlobalSettingsTest(ModuleTestCase):
with mock.patch(self.REQ_FUNC, return_value=(200, expected)) as req:
with mock.patch.object(namer, 'get_name', return_value='y'):
update = namer.update_name()
self.assertEquals(0, req.called)
self.assertEqual(0, req.called)
self.assertTrue(update)
def test_get_name(self):
@ -58,7 +58,7 @@ class GlobalSettingsTest(ModuleTestCase):
with mock.patch(self.REQ_FUNC, return_value=(200, expected)) as req:
name = namer.get_name()
self.assertEquals(name, expected['name'])
self.assertEqual(name, expected['name'])
def test_get_name_fail(self):
"""Ensure we can successfully set the name"""

View file

@ -256,7 +256,7 @@ class HostTest(ModuleTestCase):
host = Host()
host.host_exists()
self.assertTrue(host.needs_update())
self.assertEquals(host.assigned_host_ports(), {})
self.assertEqual(host.assigned_host_ports(), {})
# Change port name (force)
with mock.patch(self.REQ_FUNC, return_value=(200, self.EXISTING_HOSTS)):
@ -266,7 +266,7 @@ class HostTest(ModuleTestCase):
host = Host()
host.host_exists()
self.assertTrue(host.needs_update())
self.assertEquals(host.assigned_host_ports(), {'84000000600A098000A4B9D10030370B5D430109': ['89000000600A098000A4B28D00303CFC5D4300F7']})
self.assertEqual(host.assigned_host_ports(), {'84000000600A098000A4B9D10030370B5D430109': ['89000000600A098000A4B28D00303CFC5D4300F7']})
# Change port type
with mock.patch(self.REQ_FUNC, return_value=(200, self.EXISTING_HOSTS)):
@ -275,7 +275,7 @@ class HostTest(ModuleTestCase):
host = Host()
host.host_exists()
self.assertTrue(host.needs_update())
self.assertEquals(host.assigned_host_ports(), {})
self.assertEqual(host.assigned_host_ports(), {})
# take port from another host by force
with mock.patch(self.REQ_FUNC, return_value=(200, self.EXISTING_HOSTS)):
@ -284,7 +284,7 @@ class HostTest(ModuleTestCase):
host = Host()
host.host_exists()
self.assertTrue(host.needs_update())
self.assertEquals(host.assigned_host_ports(), {'84000000600A098000A4B9D10030370B5D430109': ['89000000600A098000A4B28D00303CFC5D4300F7']})
self.assertEqual(host.assigned_host_ports(), {'84000000600A098000A4B9D10030370B5D430109': ['89000000600A098000A4B28D00303CFC5D4300F7']})
# take port from another host by force
with mock.patch(self.REQ_FUNC, side_effect=[(200, self.EXISTING_HOSTS), (200, {})]):
@ -293,8 +293,8 @@ class HostTest(ModuleTestCase):
host = Host()
host.host_exists()
self.assertTrue(host.needs_update())
self.assertEquals(host.assigned_host_ports(apply_unassigning=True),
{'84000000600A098000A4B9D10030370B5D430109': ['89000000600A098000A4B28D00303CFC5D4300F7']})
self.assertEqual(host.assigned_host_ports(apply_unassigning=True),
{'84000000600A098000A4B9D10030370B5D430109': ['89000000600A098000A4B28D00303CFC5D4300F7']})
def test_assigned_host_ports_fail(self):
"""Verify assigned_host_ports gives expected exceptions."""
@ -486,4 +486,4 @@ class HostTest(ModuleTestCase):
self._set_args({'state': 'present', 'name': 'beegfs_metadata1', 'host_type': 'windows', 'force_port': True, 'group': 'test_group',
'ports': [{'label': 'beegfs_metadata1_iscsi_1', 'type': 'iscsi', 'port': 'iqn.1993-08.org.debian.beegfs-storage1:01:b0621126818'}]})
host = Host()
self.assertEquals(host.build_success_payload(), {'api_url': 'http://localhost/', 'ssid': '1'})
self.assertEqual(host.build_success_payload(), {'api_url': 'http://localhost/', 'ssid': '1'})

View file

@ -82,7 +82,7 @@ class IscsiInterfaceTest(ModuleTestCase):
with mock.patch(self.REQ_FUNC, return_value=(200, interfaces)):
iface = IscsiInterface()
interfaces = iface.interfaces
self.assertEquals(interfaces, expected)
self.assertEqual(interfaces, expected)
def test_interfaces_fail(self):
"""Ensure we fail gracefully on an error to retrieve the interfaces"""
@ -124,8 +124,8 @@ class IscsiInterfaceTest(ModuleTestCase):
inst = IscsiInterface()
update, body = inst.make_update_body(iface)
self.assertTrue(update, msg="An update was expected!")
self.assertEquals(body['settings']['ipv4Enabled'][0], True)
self.assertEquals(body['settings']['ipv4AddressConfigMethod'][0], 'configDhcp')
self.assertEqual(body['settings']['ipv4Enabled'][0], True)
self.assertEqual(body['settings']['ipv4AddressConfigMethod'][0], 'configDhcp')
def test_make_update_body_static(self):
"""Ensure the update body generates correctly for a transition from dhcp to static"""
@ -146,11 +146,11 @@ class IscsiInterfaceTest(ModuleTestCase):
inst = IscsiInterface()
update, body = inst.make_update_body(iface)
self.assertTrue(update, msg="An update was expected!")
self.assertEquals(body['settings']['ipv4Enabled'][0], True)
self.assertEquals(body['settings']['ipv4AddressConfigMethod'][0], 'configStatic')
self.assertEquals(body['settings']['ipv4Address'][0], '10.10.10.10')
self.assertEquals(body['settings']['ipv4SubnetMask'][0], '255.255.255.0')
self.assertEquals(body['settings']['ipv4GatewayAddress'][0], '1.1.1.1')
self.assertEqual(body['settings']['ipv4Enabled'][0], True)
self.assertEqual(body['settings']['ipv4AddressConfigMethod'][0], 'configStatic')
self.assertEqual(body['settings']['ipv4Address'][0], '10.10.10.10')
self.assertEqual(body['settings']['ipv4SubnetMask'][0], '255.255.255.0')
self.assertEqual(body['settings']['ipv4GatewayAddress'][0], '1.1.1.1')
CONTROLLERS = dict(A='1', B='2')

View file

@ -304,7 +304,7 @@ class LdapTest(ModuleTestCase):
#
# with mock.patch(self.REQ_FUNC, return_value=(200, expected)):
# config = asup.get_configuration()
# self.assertEquals(config, expected)
# self.assertEqual(config, expected)
#
# def test_update_configuration(self):
# """Validate retrieving the ASUP configuration"""
@ -398,9 +398,9 @@ class LdapTest(ModuleTestCase):
# asup = Asup()
#
# self.assertTrue(asup.asup)
# self.assertEquals(asup.days, ["sunday", "monday", "tuesday"]),
# self.assertEquals(asup.start, 1200)
# self.assertEquals(asup.end, 1439)
# self.assertEqual(asup.days, ["sunday", "monday", "tuesday"]),
# self.assertEqual(asup.start, 1200)
# self.assertEqual(asup.end, 1439)
#
# def test_init_schedule_invalid(self):
# """Validate updating ASUP with invalid schedule fails test."""

View file

@ -151,16 +151,16 @@ class TestPathDwimRelativeDataLoader(unittest.TestCase):
self._loader = DataLoader()
def test_all_slash(self):
self.assertEquals(self._loader.path_dwim_relative('/', '/', '/'), '/')
self.assertEqual(self._loader.path_dwim_relative('/', '/', '/'), '/')
def test_path_endswith_role(self):
self.assertEquals(self._loader.path_dwim_relative(path='foo/bar/tasks/', dirname='/', source='/'), '/')
self.assertEqual(self._loader.path_dwim_relative(path='foo/bar/tasks/', dirname='/', source='/'), '/')
def test_path_endswith_role_main_yml(self):
self.assertIn('main.yml', self._loader.path_dwim_relative(path='foo/bar/tasks/', dirname='/', source='main.yml'))
def test_path_endswith_role_source_tilde(self):
self.assertEquals(self._loader.path_dwim_relative(path='foo/bar/tasks/', dirname='/', source='~/'), os.path.expanduser('~'))
self.assertEqual(self._loader.path_dwim_relative(path='foo/bar/tasks/', dirname='/', source='~/'), os.path.expanduser('~'))
class TestPathDwimRelativeStackDataLoader(unittest.TestCase):
@ -178,13 +178,13 @@ class TestPathDwimRelativeStackDataLoader(unittest.TestCase):
self.assertEqual(self._loader.path_dwim_relative_stack([], '', '~/'), os.path.expanduser('~'))
def test_all_slash(self):
self.assertEquals(self._loader.path_dwim_relative_stack('/', '/', '/'), '/')
self.assertEqual(self._loader.path_dwim_relative_stack('/', '/', '/'), '/')
def test_path_endswith_role(self):
self.assertEquals(self._loader.path_dwim_relative_stack(paths=['foo/bar/tasks/'], dirname='/', source='/'), '/')
self.assertEqual(self._loader.path_dwim_relative_stack(paths=['foo/bar/tasks/'], dirname='/', source='/'), '/')
def test_path_endswith_role_source_tilde(self):
self.assertEquals(self._loader.path_dwim_relative_stack(paths=['foo/bar/tasks/'], dirname='/', source='~/'), os.path.expanduser('~'))
self.assertEqual(self._loader.path_dwim_relative_stack(paths=['foo/bar/tasks/'], dirname='/', source='~/'), os.path.expanduser('~'))
def test_path_endswith_role_source_main_yml(self):
self.assertRaises(AnsibleFileNotFound, self._loader.path_dwim_relative_stack, ['foo/bar/tasks/'], '/', 'main.yml')

View file

@ -46,7 +46,7 @@ class TestUnhexlify(unittest.TestCase):
b_plain_data = b'some text to hexlify'
b_data = hexlify(b_plain_data)
res = vault._unhexlify(b_data)
self.assertEquals(res, b_plain_data)
self.assertEqual(res, b_plain_data)
def test_odd_length(self):
b_data = b'123456789abcdefghijklmnopqrstuvwxyz'
@ -631,12 +631,12 @@ class TestMatchSecrets(unittest.TestCase):
def test_single_match(self):
secret = TextVaultSecret('password')
matches = vault.match_secrets([('default', secret)], ['default'])
self.assertEquals(matches, [('default', secret)])
self.assertEqual(matches, [('default', secret)])
def test_no_matches(self):
secret = TextVaultSecret('password')
matches = vault.match_secrets([('default', secret)], ['not_default'])
self.assertEquals(matches, [])
self.assertEqual(matches, [])
def test_multiple_matches(self):
secrets = [('vault_id1', TextVaultSecret('password1')),
@ -925,7 +925,7 @@ class TestVaultLib(unittest.TestCase):
def test_cipher_not_set(self):
plaintext = u"ansible"
self.v.encrypt(plaintext)
self.assertEquals(self.v.cipher_name, "AES256")
self.assertEqual(self.v.cipher_name, "AES256")
@pytest.mark.skipif(not vault.HAS_PYCRYPTO,

View file

@ -77,12 +77,10 @@ class TestBase(unittest.TestCase):
def _assert_copy(self, orig, copy):
self.assertIsInstance(copy, self.ClassUnderTest)
self.assertIsInstance(copy, base.Base)
self.assertEquals(len(orig._valid_attrs),
len(copy._valid_attrs))
self.assertEqual(len(orig._valid_attrs), len(copy._valid_attrs))
sentinel = 'Empty DS'
self.assertEquals(getattr(orig, '_ds', sentinel),
getattr(copy, '_ds', sentinel))
self.assertEqual(getattr(orig, '_ds', sentinel), getattr(copy, '_ds', sentinel))
def test_copy_empty(self):
copy = self.b.copy()
@ -167,20 +165,20 @@ class TestBase(unittest.TestCase):
# environment is supposed to be a list. This
# seems like it shouldn't work?
ret = self.b.load_data(ds)
self.assertEquals(True, ret._attributes['environment'])
self.assertEqual(True, ret._attributes['environment'])
def test_post_validate(self):
ds = {'environment': [],
'port': 443}
b = self._base_validate(ds)
self.assertEquals(b.port, 443)
self.assertEquals(b.environment, [])
self.assertEqual(b.port, 443)
self.assertEqual(b.environment, [])
def test_post_validate_invalid_attr_types(self):
ds = {'environment': [],
'port': 'some_port'}
b = self._base_validate(ds)
self.assertEquals(b.port, 'some_port')
self.assertEqual(b.port, 'some_port')
def test_squash(self):
data = self.b.serialize()
@ -196,7 +194,7 @@ class TestBase(unittest.TestCase):
'vars': {'var_2_key': 'var_2_value',
'var_1_key': 'var_1_value'}}
b = self._base_validate(ds)
self.assertEquals(b.vars['var_1_key'], 'var_1_value')
self.assertEqual(b.vars['var_1_key'], 'var_1_value')
def test_vars_list_of_dicts(self):
ds = {'environment': [],
@ -204,7 +202,7 @@ class TestBase(unittest.TestCase):
{'var_1_key': 'var_1_value'}]
}
b = self._base_validate(ds)
self.assertEquals(b.vars['var_1_key'], 'var_1_value')
self.assertEqual(b.vars['var_1_key'], 'var_1_value')
def test_vars_not_dict_or_list(self):
ds = {'environment': [],
@ -230,7 +228,7 @@ class TestBase(unittest.TestCase):
'vars': None
}
b = self._base_validate(ds)
self.assertEquals(b.vars, {})
self.assertEqual(b.vars, {})
def test_validate_empty(self):
self.b.validate()
@ -240,8 +238,8 @@ class TestBase(unittest.TestCase):
# not sure why these exist, but here are tests anyway
loader = self.b.get_loader()
variable_manager = self.b.get_variable_manager()
self.assertEquals(loader, self.b._loader)
self.assertEquals(variable_manager, self.b._variable_manager)
self.assertEqual(loader, self.b._loader)
self.assertEqual(variable_manager, self.b._variable_manager)
class TestExtendValue(unittest.TestCase):
@ -252,60 +250,60 @@ class TestExtendValue(unittest.TestCase):
value_list = ['first', 'second']
new_value_list = ['new_first', 'new_second']
ret = b._extend_value(value_list, new_value_list)
self.assertEquals(value_list + new_value_list, ret)
self.assertEqual(value_list + new_value_list, ret)
def test_extend_value_list_newlist_prepend(self):
b = base.Base()
value_list = ['first', 'second']
new_value_list = ['new_first', 'new_second']
ret_prepend = b._extend_value(value_list, new_value_list, prepend=True)
self.assertEquals(new_value_list + value_list, ret_prepend)
self.assertEqual(new_value_list + value_list, ret_prepend)
def test_extend_value_newlist_list(self):
b = base.Base()
value_list = ['first', 'second']
new_value_list = ['new_first', 'new_second']
ret = b._extend_value(new_value_list, value_list)
self.assertEquals(new_value_list + value_list, ret)
self.assertEqual(new_value_list + value_list, ret)
def test_extend_value_newlist_list_prepend(self):
b = base.Base()
value_list = ['first', 'second']
new_value_list = ['new_first', 'new_second']
ret = b._extend_value(new_value_list, value_list, prepend=True)
self.assertEquals(value_list + new_value_list, ret)
self.assertEqual(value_list + new_value_list, ret)
def test_extend_value_string_newlist(self):
b = base.Base()
some_string = 'some string'
new_value_list = ['new_first', 'new_second']
ret = b._extend_value(some_string, new_value_list)
self.assertEquals([some_string] + new_value_list, ret)
self.assertEqual([some_string] + new_value_list, ret)
def test_extend_value_string_newstring(self):
b = base.Base()
some_string = 'some string'
new_value_string = 'this is the new values'
ret = b._extend_value(some_string, new_value_string)
self.assertEquals([some_string, new_value_string], ret)
self.assertEqual([some_string, new_value_string], ret)
def test_extend_value_list_newstring(self):
b = base.Base()
value_list = ['first', 'second']
new_value_string = 'this is the new values'
ret = b._extend_value(value_list, new_value_string)
self.assertEquals(value_list + [new_value_string], ret)
self.assertEqual(value_list + [new_value_string], ret)
def test_extend_value_none_none(self):
b = base.Base()
ret = b._extend_value(None, None)
self.assertEquals(len(ret), 0)
self.assertEqual(len(ret), 0)
self.assertFalse(ret)
def test_extend_value_none_list(self):
b = base.Base()
ret = b._extend_value(None, ['foo'])
self.assertEquals(ret, ['foo'])
self.assertEqual(ret, ['foo'])
class ExampleException(Exception):
@ -409,13 +407,13 @@ class TestBaseSubClass(TestBase):
def test_attr_bool(self):
ds = {'test_attr_bool': True}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_bool, True)
self.assertEqual(bsc.test_attr_bool, True)
def test_attr_int(self):
MOST_RANDOM_NUMBER = 37
ds = {'test_attr_int': MOST_RANDOM_NUMBER}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_int, MOST_RANDOM_NUMBER)
self.assertEqual(bsc.test_attr_int, MOST_RANDOM_NUMBER)
def test_attr_int_del(self):
MOST_RANDOM_NUMBER = 37
@ -428,14 +426,14 @@ class TestBaseSubClass(TestBase):
roughly_pi = 4.0
ds = {'test_attr_float': roughly_pi}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_float, roughly_pi)
self.assertEqual(bsc.test_attr_float, roughly_pi)
def test_attr_percent(self):
percentage = '90%'
percentage_float = 90.0
ds = {'test_attr_percent': percentage}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_percent, percentage_float)
self.assertEqual(bsc.test_attr_percent, percentage_float)
# This method works hard and gives it its all and everything it's got. It doesn't
# leave anything on the field. It deserves to pass. It has earned it.
@ -444,7 +442,7 @@ class TestBaseSubClass(TestBase):
percentage_float = 110.11
ds = {'test_attr_percent': percentage}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_percent, percentage_float)
self.assertEqual(bsc.test_attr_percent, percentage_float)
# This method is just here for the paycheck.
def test_attr_percent_60_no_percent_sign(self):
@ -452,32 +450,32 @@ class TestBaseSubClass(TestBase):
percentage_float = 60.0
ds = {'test_attr_percent': percentage}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_percent, percentage_float)
self.assertEqual(bsc.test_attr_percent, percentage_float)
def test_attr_set(self):
test_set = set(['first_string_in_set', 'second_string_in_set'])
ds = {'test_attr_set': test_set}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_set, test_set)
self.assertEqual(bsc.test_attr_set, test_set)
def test_attr_set_string(self):
test_data = ['something', 'other']
test_value = ','.join(test_data)
ds = {'test_attr_set': test_value}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_set, set(test_data))
self.assertEqual(bsc.test_attr_set, set(test_data))
def test_attr_set_not_string_or_list(self):
test_value = 37.1
ds = {'test_attr_set': test_value}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_set, set([test_value]))
self.assertEqual(bsc.test_attr_set, set([test_value]))
def test_attr_dict(self):
test_dict = {'a_different_key': 'a_different_value'}
ds = {'test_attr_dict': test_dict}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_dict, test_dict)
self.assertEqual(bsc.test_attr_dict, test_dict)
def test_attr_dict_string(self):
test_value = 'just_some_random_string'
@ -518,7 +516,7 @@ class TestBaseSubClass(TestBase):
ds = {'remote_user': 'testuser'}
bsc = self._base_validate(ds)
# TODO: attemp to verify we called parent gettters etc
self.assertEquals(bsc.remote_user, 'testuser')
self.assertEqual(bsc.remote_user, 'testuser')
def test_attr_example_undefined(self):
ds = {'test_attr_example': '{{ some_var_that_shouldnt_exist_to_test_omit }}'}
@ -529,14 +527,14 @@ class TestBaseSubClass(TestBase):
ds = {'name': '{{ some_var_that_shouldnt_exist_to_test_omit }}'}
bsc = self._base_validate(ds)
# the attribute 'name' is special cases in post_validate
self.assertEquals(bsc.name, '{{ some_var_that_shouldnt_exist_to_test_omit }}')
self.assertEqual(bsc.name, '{{ some_var_that_shouldnt_exist_to_test_omit }}')
def test_subclass_validate_method(self):
ds = {'test_attr_list': ['string_list_item_1', 'string_list_item_2'],
'test_attr_example': 'the_test_attr_example_value_string'}
# Not throwing an exception here is the test
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_example, 'the_test_attr_example_value_string')
self.assertEqual(bsc.test_attr_example, 'the_test_attr_example_value_string')
def test_subclass_validate_method_invalid(self):
ds = {'test_attr_example': [None]}
@ -545,13 +543,13 @@ class TestBaseSubClass(TestBase):
def test_attr_none(self):
ds = {'test_attr_none': 'foo'}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_none, None)
self.assertEqual(bsc.test_attr_none, None)
def test_attr_string(self):
the_string_value = "the new test_attr_string_value"
ds = {'test_attr_string': the_string_value}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_string, the_string_value)
self.assertEqual(bsc.test_attr_string, the_string_value)
def test_attr_string_invalid_list(self):
ds = {'test_attr_string': ['The new test_attr_string', 'value, however in a list']}
@ -561,7 +559,7 @@ class TestBaseSubClass(TestBase):
the_string_value = "the new test_attr_string_required_value"
ds = {'test_attr_string_required': the_string_value}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_string_required, the_string_value)
self.assertEqual(bsc.test_attr_string_required, the_string_value)
def test_attr_list_invalid(self):
ds = {'test_attr_list': {}}
@ -571,18 +569,18 @@ class TestBaseSubClass(TestBase):
string_list = ['foo', 'bar']
ds = {'test_attr_list': string_list}
bsc = self._base_validate(ds)
self.assertEquals(string_list, bsc._attributes['test_attr_list'])
self.assertEqual(string_list, bsc._attributes['test_attr_list'])
def test_attr_list_none(self):
ds = {'test_attr_list': None}
bsc = self._base_validate(ds)
self.assertEquals(None, bsc._attributes['test_attr_list'])
self.assertEqual(None, bsc._attributes['test_attr_list'])
def test_attr_list_no_listof(self):
test_list = ['foo', 'bar', 123]
ds = {'test_attr_list_no_listof': test_list}
bsc = self._base_validate(ds)
self.assertEquals(test_list, bsc._attributes['test_attr_list_no_listof'])
self.assertEqual(test_list, bsc._attributes['test_attr_list_no_listof'])
def test_attr_list_required(self):
string_list = ['foo', 'bar']
@ -592,7 +590,7 @@ class TestBaseSubClass(TestBase):
fake_loader = DictDataLoader({})
templar = Templar(loader=fake_loader)
bsc.post_validate(templar)
self.assertEquals(string_list, bsc._attributes['test_attr_list_required'])
self.assertEqual(string_list, bsc._attributes['test_attr_list_required'])
def test_attr_list_required_empty_string(self):
string_list = [""]
@ -608,19 +606,19 @@ class TestBaseSubClass(TestBase):
a_list = ['some string']
ds = {'test_attr_unknown_isa': a_list}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_unknown_isa, a_list)
self.assertEqual(bsc.test_attr_unknown_isa, a_list)
def test_attr_method(self):
ds = {'test_attr_method': 'value from the ds'}
bsc = self._base_validate(ds)
# The value returned by the subclasses _get_attr_test_attr_method
self.assertEquals(bsc.test_attr_method, 'foo bar')
self.assertEqual(bsc.test_attr_method, 'foo bar')
def test_attr_method_missing(self):
a_string = 'The value set from the ds'
ds = {'test_attr_method_missing': a_string}
bsc = self._base_validate(ds)
self.assertEquals(bsc.test_attr_method_missing, a_string)
self.assertEqual(bsc.test_attr_method_missing, a_string)
def test_get_validated_value_string_rewrap_unsafe(self):
attribute = FieldAttribute(isa='string')
@ -629,4 +627,4 @@ class TestBaseSubClass(TestBase):
bsc = self.ClassUnderTest()
result = bsc.get_validated_value('foo', attribute, value, templar)
self.assertIsInstance(result, AnsibleUnsafeText)
self.assertEquals(result, AnsibleUnsafeText(u'bar'))
self.assertEqual(result, AnsibleUnsafeText(u'bar'))

View file

@ -138,7 +138,7 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
self._assert_is_task_list_or_blocks(res)
self.assertEquals(res[0].action, action_name)
self.assertEqual(res[0].action, action_name)
def test_block_unknown_action(self):
action_name = 'foo_test_block_unknown_action'
@ -154,11 +154,11 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
def _assert_default_block(self, block):
# the expected defaults
self.assertIsInstance(block.block, list)
self.assertEquals(len(block.block), 1)
self.assertEqual(len(block.block), 1)
self.assertIsInstance(block.rescue, list)
self.assertEquals(len(block.rescue), 0)
self.assertEqual(len(block.rescue), 0)
self.assertIsInstance(block.always, list)
self.assertEquals(len(block.always), 0)
self.assertEqual(len(block.always), 0)
def test_block_unknown_action_use_handlers(self):
ds = [{
@ -183,14 +183,14 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
self.assertIsInstance(res, list)
self.assertEquals(len(res), 0)
self.assertEqual(len(res), 0)
def test_one_bogus_include_use_handlers(self):
ds = [{'include': 'somefile.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play, use_handlers=True,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
self.assertIsInstance(res, list)
self.assertEquals(len(res), 0)
self.assertEqual(len(res), 0)
def test_one_bogus_include_static(self):
ds = [{'include': 'somefile.yml',
@ -198,13 +198,13 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
self.assertIsInstance(res, list)
self.assertEquals(len(res), 0)
self.assertEqual(len(res), 0)
def test_one_include(self):
ds = [{'include': '/dev/null/includes/other_test_include.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
self.assertEquals(len(res), 1)
self.assertEqual(len(res), 1)
self._assert_is_task_list_or_blocks(res)
def test_one_parent_include(self):
@ -280,7 +280,7 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
self.assertIsInstance(res[0], Handler)
# default for Handler
self.assertEquals(res[0].listen, [])
self.assertEqual(res[0].listen, [])
# TODO/FIXME: this doesn't seen right
# figure out how to get the non-static errors to be raised, this seems to just ignore everything
@ -298,7 +298,7 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
self._assert_is_task_list_or_blocks(res)
self.assertIsInstance(res[0], Task)
self.assertEquals(res[0].args['_raw_params'], '/dev/null/includes/static_test_include.yml')
self.assertEqual(res[0].args['_raw_params'], '/dev/null/includes/static_test_include.yml')
# TODO/FIXME: This two get stuck trying to make a mock_block into a TaskInclude
# def test_one_include(self):
@ -320,7 +320,7 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
block=self.mock_block,
variable_manager=self.mock_variable_manager, loader=self.fake_role_loader)
self.assertEquals(len(res), 1)
self.assertEqual(len(res), 1)
self._assert_is_task_list_or_blocks(res)
def test_one_bogus_include_role_use_handlers(self):
@ -329,7 +329,7 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
block=self.mock_block,
variable_manager=self.mock_variable_manager,
loader=self.fake_role_loader)
self.assertEquals(len(res), 1)
self.assertEqual(len(res), 1)
self._assert_is_task_list_or_blocks(res)

View file

@ -87,8 +87,8 @@ class TestTask(unittest.TestCase):
self.assertIn("The error appears to be in 'test_task_faux_playbook.yml", cm.exception.message)
self.assertIn(kv_bad_args_str, cm.exception.message)
self.assertIn('apk', cm.exception.message)
self.assertEquals(cm.exception.message.count('The offending line'), 1)
self.assertEquals(cm.exception.message.count('The error appears to be in'), 1)
self.assertEqual(cm.exception.message.count('The offending line'), 1)
self.assertEqual(cm.exception.message.count('The error appears to be in'), 1)
def test_task_auto_name(self):
assert 'name' not in kv_command_task

View file

@ -56,33 +56,33 @@ class TestCallbackResults(unittest.TestCase):
cb = CallbackBase()
results = {'item': 'some_item'}
res = cb._get_item(results)
self.assertEquals(res, 'some_item')
self.assertEqual(res, 'some_item')
def test_get_item_no_log(self):
cb = CallbackBase()
results = {'item': 'some_item', '_ansible_no_log': True}
res = cb._get_item(results)
self.assertEquals(res, "(censored due to no_log)")
self.assertEqual(res, "(censored due to no_log)")
results = {'item': 'some_item', '_ansible_no_log': False}
res = cb._get_item(results)
self.assertEquals(res, "some_item")
self.assertEqual(res, "some_item")
def test_get_item_label(self):
cb = CallbackBase()
results = {'item': 'some_item'}
res = cb._get_item_label(results)
self.assertEquals(res, 'some_item')
self.assertEqual(res, 'some_item')
def test_get_item_label_no_log(self):
cb = CallbackBase()
results = {'item': 'some_item', '_ansible_no_log': True}
res = cb._get_item_label(results)
self.assertEquals(res, "(censored due to no_log)")
self.assertEqual(res, "(censored due to no_log)")
results = {'item': 'some_item', '_ansible_no_log': False}
res = cb._get_item_label(results)
self.assertEquals(res, "some_item")
self.assertEqual(res, "some_item")
def test_clean_results_debug_task(self):
cb = CallbackBase()

View file

@ -84,7 +84,7 @@ class TestHost(unittest.TestCase):
hostA_clone = Host()
hostA_clone.deserialize(hostA_data)
self.assertEquals(self.hostA, hostA_clone)
self.assertEqual(self.hostA, hostA_clone)
def test_set_state(self):
group = Group('some_group')
@ -93,7 +93,7 @@ class TestHost(unittest.TestCase):
pickled_hostA = pickle.dumps(self.hostA)
hostA_clone = pickle.loads(pickled_hostA)
self.assertEquals(self.hostA, hostA_clone)
self.assertEqual(self.hostA, hostA_clone)
class TestHostWithPort(TestHost):
@ -105,4 +105,4 @@ class TestHostWithPort(TestHost):
def test_get_vars_ansible_port(self):
host_vars = self.hostA.get_vars()
self.assertEquals(host_vars['ansible_port'], self.ansible_port)
self.assertEqual(host_vars['ansible_port'], self.ansible_port)

View file

@ -239,7 +239,7 @@ class TestGenCandidateChars(unittest.TestCase):
params = testcase['params']
chars_spec = params['chars']
res = password._gen_candidate_chars(chars_spec)
self.assertEquals(res, expected_candidate_chars)
self.assertEqual(res, expected_candidate_chars)
def test_gen_candidate_chars(self):
for testcase in old_style_params_data:
@ -253,32 +253,32 @@ class TestRandomPassword(unittest.TestCase):
def test_default(self):
res = password.random_password()
self.assertEquals(len(res), password.DEFAULT_LENGTH)
self.assertEqual(len(res), password.DEFAULT_LENGTH)
self.assertTrue(isinstance(res, text_type))
self._assert_valid_chars(res, DEFAULT_CANDIDATE_CHARS)
def test_zero_length(self):
res = password.random_password(length=0)
self.assertEquals(len(res), 0)
self.assertEqual(len(res), 0)
self.assertTrue(isinstance(res, text_type))
self._assert_valid_chars(res, u',')
def test_just_a_common(self):
res = password.random_password(length=1, chars=u',')
self.assertEquals(len(res), 1)
self.assertEquals(res, u',')
self.assertEqual(len(res), 1)
self.assertEqual(res, u',')
def test_free_will(self):
# A Rush and Spinal Tap reference twofer
res = password.random_password(length=11, chars=u'a')
self.assertEquals(len(res), 11)
self.assertEquals(res, 'aaaaaaaaaaa')
self.assertEqual(len(res), 11)
self.assertEqual(res, 'aaaaaaaaaaa')
self._assert_valid_chars(res, u'a')
def test_unicode(self):
res = password.random_password(length=11, chars=u'くらとみ')
self._assert_valid_chars(res, u'くらとみ')
self.assertEquals(len(res), 11)
self.assertEqual(len(res), 11)
def test_gen_password(self):
for testcase in old_style_params_data:
@ -287,10 +287,10 @@ class TestRandomPassword(unittest.TestCase):
params_chars_spec = password._gen_candidate_chars(params['chars'])
password_string = password.random_password(length=params['length'],
chars=params_chars_spec)
self.assertEquals(len(password_string),
params['length'],
msg='generated password=%s has length (%s) instead of expected length (%s)' %
(password_string, len(password_string), params['length']))
self.assertEqual(len(password_string),
params['length'],
msg='generated password=%s has length (%s) instead of expected length (%s)' %
(password_string, len(password_string), params['length']))
for char in password_string:
self.assertIn(char, candidate_chars,
@ -301,22 +301,22 @@ class TestRandomPassword(unittest.TestCase):
class TestParseContent(unittest.TestCase):
def test_empty_password_file(self):
plaintext_password, salt = password._parse_content(u'')
self.assertEquals(plaintext_password, u'')
self.assertEquals(salt, None)
self.assertEqual(plaintext_password, u'')
self.assertEqual(salt, None)
def test(self):
expected_content = u'12345678'
file_content = expected_content
plaintext_password, salt = password._parse_content(file_content)
self.assertEquals(plaintext_password, expected_content)
self.assertEquals(salt, None)
self.assertEqual(plaintext_password, expected_content)
self.assertEqual(salt, None)
def test_with_salt(self):
expected_content = u'12345678 salt=87654321'
file_content = expected_content
plaintext_password, salt = password._parse_content(file_content)
self.assertEquals(plaintext_password, u'12345678')
self.assertEquals(salt, u'87654321')
self.assertEqual(plaintext_password, u'12345678')
self.assertEqual(salt, u'87654321')
class TestFormatContent(unittest.TestCase):
@ -419,7 +419,7 @@ class TestLookupModuleWithoutPasslib(BaseTestLookupModule):
results = self.password_lookup.run([u'/path/to/somewhere chars=a'], None)
for result in results:
self.assertEquals(result, u'a' * password.DEFAULT_LENGTH)
self.assertEqual(result, u'a' * password.DEFAULT_LENGTH)
@patch('time.sleep')
def test_lock_been_held(self, mock_sleep):
@ -473,7 +473,7 @@ class TestLookupModuleWithPasslib(BaseTestLookupModule):
expected_password_length = 76
for result in results:
self.assertEquals(len(result), expected_password_length)
self.assertEqual(len(result), expected_password_length)
# result should have 5 parts split by '$'
str_parts = result.split('$', 5)
@ -481,12 +481,12 @@ class TestLookupModuleWithPasslib(BaseTestLookupModule):
crypt_parts = passlib.hash.pbkdf2_sha256.parsehash(result)
# verify it used the right algo type
self.assertEquals(str_parts[1], 'pbkdf2-sha256')
self.assertEqual(str_parts[1], 'pbkdf2-sha256')
self.assertEquals(len(str_parts), 5)
self.assertEqual(len(str_parts), 5)
# verify the string and parsehash agree on the number of rounds
self.assertEquals(int(str_parts[2]), crypt_parts['rounds'])
self.assertEqual(int(str_parts[2]), crypt_parts['rounds'])
self.assertIsInstance(result, text_type)
@patch.object(PluginLoader, '_get_paths')

View file

@ -78,31 +78,31 @@ class TestBackslashEscape(unittest.TestCase):
for test in self.test_data:
intermediate = _escape_backslashes(test['template'], self.env)
self.assertEquals(intermediate, test['intermediate'])
self.assertEqual(intermediate, test['intermediate'])
template = jinja2.Template(intermediate)
args = test['args']
self.assertEquals(template.render(**args), test['expectation'])
self.assertEqual(template.render(**args), test['expectation'])
class TestCountNewlines(unittest.TestCase):
def test_zero_length_string(self):
self.assertEquals(_count_newlines_from_end(u''), 0)
self.assertEqual(_count_newlines_from_end(u''), 0)
def test_short_string(self):
self.assertEquals(_count_newlines_from_end(u'The quick\n'), 1)
self.assertEqual(_count_newlines_from_end(u'The quick\n'), 1)
def test_one_newline(self):
self.assertEquals(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' * 1000 + u'\n'), 1)
self.assertEqual(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' * 1000 + u'\n'), 1)
def test_multiple_newlines(self):
self.assertEquals(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' * 1000 + u'\n\n\n'), 3)
self.assertEqual(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' * 1000 + u'\n\n\n'), 3)
def test_zero_newlines(self):
self.assertEquals(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' * 1000), 0)
self.assertEqual(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' * 1000), 0)
def test_all_newlines(self):
self.assertEquals(_count_newlines_from_end(u'\n' * 10), 10)
self.assertEqual(_count_newlines_from_end(u'\n' * 10), 10)
def test_mostly_newlines(self):
self.assertEquals(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' + u'\n' * 1000), 1000)
self.assertEqual(_count_newlines_from_end(u'The quick brown fox jumped over the lazy dog' + u'\n' * 1000), 1000)