change assert(Not)Equals to assert(Not)Equal

According to http://docs.python.org/2/library/unittest.html
assert(Not)Equals is a deprecated alias of assert(Not)Equal.

Change-Id: Iac2d5eefe47b96efc787c6eca5ca014ca3b3910c
Closes-Bug: #1329757
This commit is contained in:
zhangyangyang 2017-09-12 15:44:20 +08:00
parent 0161dde796
commit 29f42fa5de
2 changed files with 42 additions and 42 deletions

View File

@ -317,8 +317,8 @@ class NovaCCHooksTests(CharmTestCase):
relation_id=None), relation_id=None),
call(authorized_keys_max_index=3, relation_id=None), call(authorized_keys_max_index=3, relation_id=None),
call(known_hosts_max_index=3, relation_id=None)] call(known_hosts_max_index=3, relation_id=None)]
self.assertEquals(sorted(self.relation_set.call_args_list), self.assertEqual(sorted(self.relation_set.call_args_list),
sorted(expected_relations)) sorted(expected_relations))
@patch.object(hooks, 'is_db_initialised') @patch.object(hooks, 'is_db_initialised')
def test_compute_changed_nova_public_key(self, mock_is_db_initialised): def test_compute_changed_nova_public_key(self, mock_is_db_initialised):
@ -350,8 +350,8 @@ class NovaCCHooksTests(CharmTestCase):
relation_id=None), relation_id=None),
call(relation_settings={'nova_authorized_keys_max_index': 3}, call(relation_settings={'nova_authorized_keys_max_index': 3},
relation_id=None)] relation_id=None)]
self.assertEquals(sorted(self.relation_set.call_args_list), self.assertEqual(sorted(self.relation_set.call_args_list),
sorted(expected_relations)) sorted(expected_relations))
@patch.object(hooks, 'canonical_url') @patch.object(hooks, 'canonical_url')
@patch.object(utils, 'config') @patch.object(utils, 'config')
@ -690,8 +690,8 @@ class NovaCCHooksTests(CharmTestCase):
self.os_release.return_value = 'diablo' self.os_release.return_value = 'diablo'
self.is_relation_made.return_value = True self.is_relation_made.return_value = True
hooks.amqp_changed() hooks.amqp_changed()
self.assertEquals(configs.write.call_args_list, self.assertEqual(configs.write.call_args_list,
[call('/etc/nova/nova.conf')]) [call('/etc/nova/nova.conf')])
cell_joined.assert_called_with(rid='nova-cell-api/0') cell_joined.assert_called_with(rid='nova-cell-api/0')
api_joined.assert_called_with(rid='nova-api/0') api_joined.assert_called_with(rid='nova-api/0')
quantum_joined.assert_called_with(rid='quantum-service/0', quantum_joined.assert_called_with(rid='quantum-service/0',
@ -719,8 +719,8 @@ class NovaCCHooksTests(CharmTestCase):
self.network_manager.return_value = 'neutron' self.network_manager.return_value = 'neutron'
self.os_release.return_value = 'diablo' self.os_release.return_value = 'diablo'
hooks.amqp_changed() hooks.amqp_changed()
self.assertEquals(configs.write.call_args_list, self.assertEqual(configs.write.call_args_list,
[call('/etc/nova/nova.conf')]) [call('/etc/nova/nova.conf')])
cell_joined.assert_called_with(rid='nova-cell-api/0') cell_joined.assert_called_with(rid='nova-cell-api/0')
api_joined.assert_called_with(rid='nova-api/0') api_joined.assert_called_with(rid='nova-api/0')
quantum_joined.assert_called_with(rid='quantum-service/0', quantum_joined.assert_called_with(rid='quantum-service/0',
@ -746,7 +746,7 @@ class NovaCCHooksTests(CharmTestCase):
'cell_type': 'parent', 'cell_type': 'parent',
'cell_name': 'api', 'cell_name': 'api',
} }
self.assertEquals(hooks.get_cell_type(), 'parent') self.assertEqual(hooks.get_cell_type(), 'parent')
@patch.object(hooks, 'canonical_url') @patch.object(hooks, 'canonical_url')
@patch.object(os, 'rename') @patch.object(os, 'rename')

View File

@ -255,19 +255,19 @@ class NovaCCUtilsTests(CharmTestCase):
def test_console_attributes_none(self): def test_console_attributes_none(self):
self.test_config.set('console-access-protocol', 'None') self.test_config.set('console-access-protocol', 'None')
_proto = utils.console_attributes('protocol') _proto = utils.console_attributes('protocol')
self.assertEquals(_proto, None) self.assertEqual(_proto, None)
self.test_config.set('console-access-protocol', 'NONE') self.test_config.set('console-access-protocol', 'NONE')
_proto = utils.console_attributes('protocol') _proto = utils.console_attributes('protocol')
self.assertEquals(_proto, None) self.assertEqual(_proto, None)
self.test_config.set('console-access-protocol', 'none') self.test_config.set('console-access-protocol', 'none')
_proto = utils.console_attributes('protocol') _proto = utils.console_attributes('protocol')
self.assertEquals(_proto, None) self.assertEqual(_proto, None)
self.test_config.set('console-access-protocol', None) self.test_config.set('console-access-protocol', None)
_proto = utils.console_attributes('protocol') _proto = utils.console_attributes('protocol')
self.assertEquals(_proto, None) self.assertEqual(_proto, None)
self.test_config.set('console-access-protocol', "") self.test_config.set('console-access-protocol', "")
_proto = utils.console_attributes('protocol') _proto = utils.console_attributes('protocol')
self.assertEquals(_proto, None) self.assertEqual(_proto, None)
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_resource_map_console_spice(self, subcontext): def test_resource_map_console_spice(self, subcontext):
@ -301,7 +301,7 @@ class NovaCCUtilsTests(CharmTestCase):
self._resource_map() self._resource_map()
_map = utils.restart_map() _map = utils.restart_map()
self.assertIsInstance(_map, OrderedDict) self.assertIsInstance(_map, OrderedDict)
self.assertEquals(_map, RESTART_MAP_ICEHOUSE) self.assertEqual(_map, RESTART_MAP_ICEHOUSE)
@patch('charmhelpers.contrib.openstack.neutron.os_release') @patch('charmhelpers.contrib.openstack.neutron.os_release')
@patch('os.path.exists') @patch('os.path.exists')
@ -315,7 +315,7 @@ class NovaCCUtilsTests(CharmTestCase):
self._resource_map() self._resource_map()
_map = utils.restart_map() _map = utils.restart_map()
self.assertIsInstance(_map, OrderedDict) self.assertIsInstance(_map, OrderedDict)
self.assertEquals(_map, RESTART_MAP_OCATA_ACTUAL) self.assertEqual(_map, RESTART_MAP_OCATA_ACTUAL)
@patch('charmhelpers.contrib.openstack.neutron.os_release') @patch('charmhelpers.contrib.openstack.neutron.os_release')
@patch('os.path.exists') @patch('os.path.exists')
@ -329,7 +329,7 @@ class NovaCCUtilsTests(CharmTestCase):
self._resource_map() self._resource_map()
_map = utils.restart_map(actual_services=False) _map = utils.restart_map(actual_services=False)
self.assertIsInstance(_map, OrderedDict) self.assertIsInstance(_map, OrderedDict)
self.assertEquals(_map, RESTART_MAP_OCATA_BASE) self.assertEqual(_map, RESTART_MAP_OCATA_BASE)
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
@patch('os.path.exists') @patch('os.path.exists')
@ -345,7 +345,7 @@ class NovaCCUtilsTests(CharmTestCase):
def test_console_attributes_spice(self): def test_console_attributes_spice(self):
_proto = utils.console_attributes('protocol', proto='spice') _proto = utils.console_attributes('protocol', proto='spice')
self.assertEquals(_proto, 'spice') self.assertEqual(_proto, 'spice')
def test_console_attributes_vnc(self): def test_console_attributes_vnc(self):
self.test_config.set('console-access-protocol', 'vnc') self.test_config.set('console-access-protocol', 'vnc')
@ -355,10 +355,10 @@ class NovaCCUtilsTests(CharmTestCase):
_proxy_page = utils.console_attributes('proxy-page') _proxy_page = utils.console_attributes('proxy-page')
vnc_pkgs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth'] vnc_pkgs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth']
vnc_servs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth'] vnc_servs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth']
self.assertEquals(_proto, 'vnc') self.assertEqual(_proto, 'vnc')
self.assertEquals(_servs, vnc_servs) self.assertEqual(_servs, vnc_servs)
self.assertEquals(_pkgs, vnc_pkgs) self.assertEqual(_pkgs, vnc_pkgs)
self.assertEquals(_proxy_page, None) self.assertEqual(_proxy_page, None)
def test_database_setup(self): def test_database_setup(self):
self.relation_ids.return_value = ['shared-db:12'] self.relation_ids.return_value = ['shared-db:12']
@ -410,7 +410,7 @@ class NovaCCUtilsTests(CharmTestCase):
ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES)) ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES))
# nova-placement-api is purposely dropped unless it's ocata # nova-placement-api is purposely dropped unless it's ocata
ex.remove('nova-placement-api') ex.remove('nova-placement-api')
self.assertEquals(ex, pkgs) self.assertEqual(ex, pkgs)
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
@patch.object(utils, 'git_install_requested') @patch.object(utils, 'git_install_requested')
@ -422,7 +422,7 @@ class NovaCCUtilsTests(CharmTestCase):
self.enable_memcache.return_value = False self.enable_memcache.return_value = False
pkgs = utils.determine_packages() pkgs = utils.determine_packages()
ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES)) ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES))
self.assertEquals(ex, pkgs) self.assertEqual(ex, pkgs)
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
@patch.object(utils, 'git_install_requested') @patch.object(utils, 'git_install_requested')
@ -460,7 +460,7 @@ class NovaCCUtilsTests(CharmTestCase):
} }
ports = utils.determine_ports() ports = utils.determine_ports()
ex = [8773, 8774] ex = [8773, 8774]
self.assertEquals(ex, sorted(ports)) self.assertEqual(ex, sorted(ports))
def test_save_script_rc_base(self): def test_save_script_rc_base(self):
self.relation_ids.return_value = [] self.relation_ids.return_value = []
@ -476,20 +476,20 @@ class NovaCCUtilsTests(CharmTestCase):
# icehouse -> liberty # icehouse -> liberty
self.os_release.return_value = 'icehouse' self.os_release.return_value = 'icehouse'
self.assertEquals( self.assertEqual(
utils.get_step_upgrade_source('cloud:trusty-liberty'), utils.get_step_upgrade_source('cloud:trusty-liberty'),
'cloud:trusty-kilo') 'cloud:trusty-kilo')
# juno -> liberty # juno -> liberty
self.os_release.return_value = 'juno' self.os_release.return_value = 'juno'
self.assertEquals( self.assertEqual(
utils.get_step_upgrade_source('cloud:trusty-liberty'), utils.get_step_upgrade_source('cloud:trusty-liberty'),
'cloud:trusty-kilo') 'cloud:trusty-kilo')
# kilo -> liberty # kilo -> liberty
self.os_release.return_value = 'kilo' self.os_release.return_value = 'kilo'
with patch_open() as (_open, _file): with patch_open() as (_open, _file):
self.assertEquals( self.assertEqual(
utils.get_step_upgrade_source('cloud:trusty-liberty'), utils.get_step_upgrade_source('cloud:trusty-liberty'),
None) None)
@ -572,8 +572,8 @@ class NovaCCUtilsTests(CharmTestCase):
def test_ssh_directory_for_unit(self, isdir, mkdir, _open): def test_ssh_directory_for_unit(self, isdir, mkdir, _open):
self.remote_unit.return_value = 'nova-compute/0' self.remote_unit.return_value = 'nova-compute/0'
isdir.return_value = False isdir.return_value = False
self.assertEquals(utils.ssh_directory_for_unit(), self.assertEqual(utils.ssh_directory_for_unit(),
'/etc/nova/compute_ssh/nova-compute') '/etc/nova/compute_ssh/nova-compute')
self.assertIn([ self.assertIn([
call('/etc/nova/compute_ssh/nova-compute/authorized_keys', 'w'), call('/etc/nova/compute_ssh/nova-compute/authorized_keys', 'w'),
call('/etc/nova/compute_ssh/nova-compute/known_hosts', 'w') call('/etc/nova/compute_ssh/nova-compute/known_hosts', 'w')
@ -582,17 +582,17 @@ class NovaCCUtilsTests(CharmTestCase):
@patch.object(utils, 'ssh_directory_for_unit') @patch.object(utils, 'ssh_directory_for_unit')
def test_known_hosts(self, ssh_dir): def test_known_hosts(self, ssh_dir):
ssh_dir.return_value = '/tmp/foo' ssh_dir.return_value = '/tmp/foo'
self.assertEquals(utils.known_hosts(), '/tmp/foo/known_hosts') self.assertEqual(utils.known_hosts(), '/tmp/foo/known_hosts')
ssh_dir.assert_called_with(None, None) ssh_dir.assert_called_with(None, None)
self.assertEquals(utils.known_hosts('bar'), '/tmp/foo/known_hosts') self.assertEqual(utils.known_hosts('bar'), '/tmp/foo/known_hosts')
ssh_dir.assert_called_with('bar', None) ssh_dir.assert_called_with('bar', None)
@patch.object(utils, 'ssh_directory_for_unit') @patch.object(utils, 'ssh_directory_for_unit')
def test_authorized_keys(self, ssh_dir): def test_authorized_keys(self, ssh_dir):
ssh_dir.return_value = '/tmp/foo' ssh_dir.return_value = '/tmp/foo'
self.assertEquals(utils.authorized_keys(), '/tmp/foo/authorized_keys') self.assertEqual(utils.authorized_keys(), '/tmp/foo/authorized_keys')
ssh_dir.assert_called_with(None, None) ssh_dir.assert_called_with(None, None)
self.assertEquals( self.assertEqual(
utils.authorized_keys('bar'), utils.authorized_keys('bar'),
'/tmp/foo/authorized_keys') '/tmp/foo/authorized_keys')
ssh_dir.assert_called_with('bar', None) ssh_dir.assert_called_with('bar', None)
@ -647,7 +647,7 @@ class NovaCCUtilsTests(CharmTestCase):
def test_determine_endpoints_base(self): def test_determine_endpoints_base(self):
self.relation_ids.return_value = [] self.relation_ids.return_value = []
self.os_release.return_value = 'diablo' self.os_release.return_value = 'diablo'
self.assertEquals( self.assertEqual(
BASE_ENDPOINTS, utils.determine_endpoints('http://foohost.com', BASE_ENDPOINTS, utils.determine_endpoints('http://foohost.com',
'http://foohost.com', 'http://foohost.com',
'http://foohost.com')) 'http://foohost.com'))
@ -672,7 +672,7 @@ class NovaCCUtilsTests(CharmTestCase):
_known_hosts.return_value = '/foo/known_hosts' _known_hosts.return_value = '/foo/known_hosts'
_check_output.return_value = '' _check_output.return_value = ''
key = utils.ssh_known_host_key('test') key = utils.ssh_known_host_key('test')
self.assertEquals(key, None) self.assertEqual(key, None)
@patch.object(utils, 'known_hosts') @patch.object(utils, 'known_hosts')
@patch('subprocess.check_call') @patch('subprocess.check_call')
@ -969,19 +969,19 @@ class NovaCCUtilsTests(CharmTestCase):
call('nova', shell='/bin/bash', system_user=True), call('nova', shell='/bin/bash', system_user=True),
call('neutron', shell='/bin/bash', system_user=True), call('neutron', shell='/bin/bash', system_user=True),
] ]
self.assertEquals(adduser.call_args_list, expected) self.assertEqual(adduser.call_args_list, expected)
check_call.assert_called_with(['usermod', '--home', '/var/lib/nova', check_call.assert_called_with(['usermod', '--home', '/var/lib/nova',
'nova']) 'nova'])
expected = [ expected = [
call('nova', system_group=True), call('nova', system_group=True),
call('neutron', system_group=True), call('neutron', system_group=True),
] ]
self.assertEquals(add_group.call_args_list, expected) self.assertEqual(add_group.call_args_list, expected)
expected = [ expected = [
call('nova', 'nova'), call('nova', 'nova'),
call('neutron', 'neutron'), call('neutron', 'neutron'),
] ]
self.assertEquals(add_user_to_group.call_args_list, expected) self.assertEqual(add_user_to_group.call_args_list, expected)
expected = [ expected = [
call('/var/lib/nova', owner='nova', call('/var/lib/nova', owner='nova',
group='nova', perms=0755, force=False), group='nova', perms=0755, force=False),
@ -1020,7 +1020,7 @@ class NovaCCUtilsTests(CharmTestCase):
call('/etc/neutron/plugins/ml2', owner='nova', call('/etc/neutron/plugins/ml2', owner='nova',
group='nova', perms=0755, force=False), group='nova', perms=0755, force=False),
] ]
self.assertEquals(mkdir.call_args_list, expected) self.assertEqual(mkdir.call_args_list, expected)
@patch('os.listdir') @patch('os.listdir')
@patch('os.path.join') @patch('os.path.join')
@ -1197,7 +1197,7 @@ class NovaCCUtilsTests(CharmTestCase):
nova_xvpvncproxy_context, perms=0o644, nova_xvpvncproxy_context, perms=0o644,
templates_dir='joined-string'), templates_dir='joined-string'),
] ]
self.assertEquals(self.render.call_args_list, expected) self.assertEqual(self.render.call_args_list, expected)
self.assertTrue(self.apt_update.called) self.assertTrue(self.apt_update.called)
self.apt_install.assert_called_with(['novnc', 'spice-html5', self.apt_install.assert_called_with(['novnc', 'spice-html5',
'websockify'], fatal=True) 'websockify'], fatal=True)
@ -1255,7 +1255,7 @@ class NovaCCUtilsTests(CharmTestCase):
'joined-string', {'daemon_path': 'joined-string'}, 'joined-string', {'daemon_path': 'joined-string'},
perms=420), perms=420),
] ]
self.assertEquals(self.render.call_args_list, expected) self.assertEqual(self.render.call_args_list, expected)
def _test_is_api_ready(self, tgt): def _test_is_api_ready(self, tgt):
fake_config = MagicMock() fake_config = MagicMock()