summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-05-12 16:43:11 -0400
committerScott Moser <smoser@ubuntu.com>2016-05-12 16:43:11 -0400
commit4ba4df2f00ab1763920280f76e2b4497898858af (patch)
treef025371acd895680336026ebdff7ffa8a4db25d3 /tests
parentf6b318947d0be752e7c93708413929802006a66e (diff)
downloadvyos-cloud-init-4ba4df2f00ab1763920280f76e2b4497898858af.tar.gz
vyos-cloud-init-4ba4df2f00ab1763920280f76e2b4497898858af.zip
run flake8 instead of pyflakes in tox. expect tests/ to pass flake8.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/helpers.py2
-rw-r--r--tests/unittests/test_builtin_handlers.py4
-rw-r--r--tests/unittests/test_cli.py4
-rw-r--r--tests/unittests/test_data.py49
-rw-r--r--tests/unittests/test_datasource/test_altcloud.py48
-rw-r--r--tests/unittests/test_datasource/test_azure.py18
-rw-r--r--tests/unittests/test_datasource/test_azure_helper.py1
-rw-r--r--tests/unittests/test_datasource/test_cloudstack.py1
-rw-r--r--tests/unittests/test_datasource/test_configdrive.py8
-rw-r--r--tests/unittests/test_datasource/test_digitalocean.py2
-rw-r--r--tests/unittests/test_datasource/test_gce.py2
-rw-r--r--tests/unittests/test_datasource/test_maas.py4
-rw-r--r--tests/unittests/test_datasource/test_nocloud.py2
-rw-r--r--tests/unittests/test_datasource/test_openstack.py70
-rw-r--r--tests/unittests/test_datasource/test_smartos.py110
-rw-r--r--tests/unittests/test_distros/test_generic.py10
-rw-r--r--tests/unittests/test_distros/test_hostname.py12
-rw-r--r--tests/unittests/test_distros/test_hosts.py18
-rw-r--r--tests/unittests/test_distros/test_netconfig.py37
-rw-r--r--tests/unittests/test_distros/test_resolv.py21
-rw-r--r--tests/unittests/test_distros/test_sysconfig.py27
-rw-r--r--tests/unittests/test_distros/test_user_data_normalize.py74
-rw-r--r--tests/unittests/test_ec2_util.py36
-rw-r--r--tests/unittests/test_filters/test_launch_index.py2
-rw-r--r--tests/unittests/test_handler/test_handler_apt_configure.py2
-rw-r--r--tests/unittests/test_handler/test_handler_ca_certs.py14
-rw-r--r--tests/unittests/test_handler/test_handler_chef.py14
-rw-r--r--tests/unittests/test_handler/test_handler_growpart.py2
-rw-r--r--tests/unittests/test_handler/test_handler_locale.py2
-rw-r--r--tests/unittests/test_handler/test_handler_lxd.py22
-rw-r--r--tests/unittests/test_handler/test_handler_power_state.py2
-rw-r--r--tests/unittests/test_handler/test_handler_rsyslog.py2
-rw-r--r--tests/unittests/test_handler/test_handler_seed_random.py12
-rw-r--r--tests/unittests/test_handler/test_handler_set_hostname.py16
-rw-r--r--tests/unittests/test_handler/test_handler_snappy.py1
-rw-r--r--tests/unittests/test_handler/test_handler_timezone.py10
-rw-r--r--tests/unittests/test_handler/test_handler_write_files.py4
-rw-r--r--tests/unittests/test_handler/test_handler_yum_add_repo.py13
-rw-r--r--tests/unittests/test_merging.py18
-rw-r--r--tests/unittests/test_net.py5
-rw-r--r--tests/unittests/test_reporting.py2
-rw-r--r--tests/unittests/test_rh_subscription.py3
-rw-r--r--tests/unittests/test_runs/test_merge_run.py6
-rw-r--r--tests/unittests/test_runs/test_simple_run.py4
-rw-r--r--tests/unittests/test_templating.py8
45 files changed, 355 insertions, 369 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index fb9c83a7..50b2bd72 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -2,8 +2,8 @@ from __future__ import print_function
import functools
import os
-import sys
import shutil
+import sys
import tempfile
import unittest
diff --git a/tests/unittests/test_builtin_handlers.py b/tests/unittests/test_builtin_handlers.py
index ad32d0b2..dea908d7 100644
--- a/tests/unittests/test_builtin_handlers.py
+++ b/tests/unittests/test_builtin_handlers.py
@@ -40,7 +40,7 @@ class TestBuiltins(test_helpers.FilesystemMockingTestCase):
'test.conf', 'blah', freq)
h.handle_part('', handlers.CONTENT_END,
None, None, None)
- self.assertEquals(0, len(os.listdir(up_root)))
+ self.assertEqual(0, len(os.listdir(up_root)))
def test_upstart_frequency_single(self):
# files should be written out when frequency is ! per-instance
@@ -67,7 +67,7 @@ class TestBuiltins(test_helpers.FilesystemMockingTestCase):
h.handle_part('', handlers.CONTENT_END,
None, None, None)
- self.assertEquals(len(os.listdir('/etc/upstart')), 1)
+ self.assertEqual(len(os.listdir('/etc/upstart')), 1)
mockobj.assert_called_once_with(
['initctl', 'reload-configuration'], capture=False)
diff --git a/tests/unittests/test_cli.py b/tests/unittests/test_cli.py
index ed863399..f537bd83 100644
--- a/tests/unittests/test_cli.py
+++ b/tests/unittests/test_cli.py
@@ -1,7 +1,7 @@
import imp
import os
-import sys
import six
+import sys
from . import helpers as test_helpers
@@ -31,7 +31,7 @@ class TestCLI(test_helpers.FilesystemMockingTestCase):
'cli', open(BIN_CLOUDINIT), '', ('', 'r', imp.PY_SOURCE))
try:
return cli.main()
- except:
+ except Exception:
pass
@test_helpers.skipIf(not os.path.isfile(BIN_CLOUDINIT), "no bin/cloudinit")
diff --git a/tests/unittests/test_data.py b/tests/unittests/test_data.py
index 9c1ec1d4..1923e2af 100644
--- a/tests/unittests/test_data.py
+++ b/tests/unittests/test_data.py
@@ -106,9 +106,9 @@ class TestConsumeUserData(helpers.FilesystemMockingTestCase):
ci.consume_data()
cc_contents = util.load_file(ci.paths.get_ipath("cloud_config"))
cc = util.load_yaml(cc_contents)
- self.assertEquals(2, len(cc))
- self.assertEquals('qux', cc['baz'])
- self.assertEquals('qux2', cc['bar'])
+ self.assertEqual(2, len(cc))
+ self.assertEqual('qux', cc['baz'])
+ self.assertEqual('qux2', cc['bar'])
def test_simple_jsonp_vendor_and_user(self):
# test that user-data wins over vendor
@@ -145,9 +145,9 @@ class TestConsumeUserData(helpers.FilesystemMockingTestCase):
(_which_ran, _failures) = mods.run_section('cloud_init_modules')
cfg = mods.cfg
self.assertIn('vendor_data', cfg)
- self.assertEquals('qux', cfg['baz'])
- self.assertEquals('qux2', cfg['bar'])
- self.assertEquals('quxC', cfg['foo'])
+ self.assertEqual('qux', cfg['baz'])
+ self.assertEqual('qux2', cfg['bar'])
+ self.assertEqual('quxC', cfg['foo'])
def test_simple_jsonp_no_vendor_consumed(self):
# make sure that vendor data is not consumed
@@ -184,8 +184,8 @@ class TestConsumeUserData(helpers.FilesystemMockingTestCase):
mods = stages.Modules(initer)
(_which_ran, _failures) = mods.run_section('cloud_init_modules')
cfg = mods.cfg
- self.assertEquals('qux', cfg['baz'])
- self.assertEquals('qux2', cfg['bar'])
+ self.assertEqual('qux', cfg['baz'])
+ self.assertEqual('qux2', cfg['bar'])
self.assertNotIn('foo', cfg)
def test_mixed_cloud_config(self):
@@ -222,8 +222,8 @@ c: d
ci.consume_data()
cc_contents = util.load_file(ci.paths.get_ipath("cloud_config"))
cc = util.load_yaml(cc_contents)
- self.assertEquals(1, len(cc))
- self.assertEquals('c', cc['a'])
+ self.assertEqual(1, len(cc))
+ self.assertEqual('c', cc['a'])
def test_vendor_user_yaml_cloud_config(self):
vendor_blob = '''
@@ -263,8 +263,8 @@ run:
(_which_ran, _failures) = mods.run_section('cloud_init_modules')
cfg = mods.cfg
self.assertIn('vendor_data', cfg)
- self.assertEquals('c', cfg['a'])
- self.assertEquals('user', cfg['name'])
+ self.assertEqual('c', cfg['a'])
+ self.assertEqual('user', cfg['name'])
self.assertNotIn('x', cfg['run'])
self.assertNotIn('y', cfg['run'])
self.assertIn('z', cfg['run'])
@@ -358,10 +358,10 @@ p: 1
None)
contents = util.load_file(paths.get_ipath('cloud_config'))
contents = util.load_yaml(contents)
- self.assertEquals(contents['run'], ['b', 'c', 'stuff', 'morestuff'])
- self.assertEquals(contents['a'], 'be')
- self.assertEquals(contents['e'], [1, 2, 3])
- self.assertEquals(contents['p'], 1)
+ self.assertEqual(contents['run'], ['b', 'c', 'stuff', 'morestuff'])
+ self.assertEqual(contents['a'], 'be')
+ self.assertEqual(contents['e'], [1, 2, 3])
+ self.assertEqual(contents['p'], 1)
def test_unhandled_type_warning(self):
"""Raw text without magic is ignored but shows warning."""
@@ -411,10 +411,10 @@ c: 4
contents = util.load_file(ci.paths.get_ipath("cloud_config"))
contents = util.load_yaml(contents)
self.assertTrue(isinstance(contents, dict))
- self.assertEquals(3, len(contents))
- self.assertEquals(2, contents['a'])
- self.assertEquals(3, contents['b'])
- self.assertEquals(4, contents['c'])
+ self.assertEqual(3, len(contents))
+ self.assertEqual(2, contents['a'])
+ self.assertEqual(3, contents['b'])
+ self.assertEqual(4, contents['c'])
def test_mime_text_plain(self):
"""Mime message of type text/plain is ignored but shows warning."""
@@ -449,8 +449,7 @@ c: 4
mockobj.assert_has_calls([
mock.call(outpath, script, 0o700),
- mock.call(ci.paths.get_ipath("cloud_config"), "", 0o600),
- ])
+ mock.call(ci.paths.get_ipath("cloud_config"), "", 0o600)])
def test_mime_text_x_shellscript(self):
"""Mime message of type text/x-shellscript is treated as script."""
@@ -470,8 +469,7 @@ c: 4
mockobj.assert_has_calls([
mock.call(outpath, script, 0o700),
- mock.call(ci.paths.get_ipath("cloud_config"), "", 0o600),
- ])
+ mock.call(ci.paths.get_ipath("cloud_config"), "", 0o600)])
def test_mime_text_plain_shell(self):
"""Mime type text/plain starting #!/bin/sh is treated as script."""
@@ -491,8 +489,7 @@ c: 4
mockobj.assert_has_calls([
mock.call(outpath, script, 0o700),
- mock.call(ci.paths.get_ipath("cloud_config"), "", 0o600),
- ])
+ mock.call(ci.paths.get_ipath("cloud_config"), "", 0o600)])
def test_mime_application_octet_stream(self):
"""Mime type application/octet-stream is ignored but shows warning."""
diff --git a/tests/unittests/test_datasource/test_altcloud.py b/tests/unittests/test_datasource/test_altcloud.py
index 85759c68..12966563 100644
--- a/tests/unittests/test_datasource/test_altcloud.py
+++ b/tests/unittests/test_datasource/test_altcloud.py
@@ -134,7 +134,7 @@ class TestGetCloudType(TestCase):
'''
util.read_dmi_data = _dmi_data('RHEV')
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals('RHEV', dsrc.get_cloud_type())
+ self.assertEqual('RHEV', dsrc.get_cloud_type())
def test_vsphere(self):
'''
@@ -143,7 +143,7 @@ class TestGetCloudType(TestCase):
'''
util.read_dmi_data = _dmi_data('VMware Virtual Platform')
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals('VSPHERE', dsrc.get_cloud_type())
+ self.assertEqual('VSPHERE', dsrc.get_cloud_type())
def test_unknown(self):
'''
@@ -152,7 +152,7 @@ class TestGetCloudType(TestCase):
'''
util.read_dmi_data = _dmi_data('Unrecognized Platform')
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals('UNKNOWN', dsrc.get_cloud_type())
+ self.assertEqual('UNKNOWN', dsrc.get_cloud_type())
class TestGetDataCloudInfoFile(TestCase):
@@ -187,7 +187,7 @@ class TestGetDataCloudInfoFile(TestCase):
_write_cloud_info_file('RHEV')
dsrc = DataSourceAltCloud({}, None, self.paths)
dsrc.user_data_rhevm = lambda: True
- self.assertEquals(True, dsrc.get_data())
+ self.assertEqual(True, dsrc.get_data())
def test_vsphere(self):
'''Success Test module get_data() forcing VSPHERE.'''
@@ -195,7 +195,7 @@ class TestGetDataCloudInfoFile(TestCase):
_write_cloud_info_file('VSPHERE')
dsrc = DataSourceAltCloud({}, None, self.paths)
dsrc.user_data_vsphere = lambda: True
- self.assertEquals(True, dsrc.get_data())
+ self.assertEqual(True, dsrc.get_data())
def test_fail_rhev(self):
'''Failure Test module get_data() forcing RHEV.'''
@@ -203,7 +203,7 @@ class TestGetDataCloudInfoFile(TestCase):
_write_cloud_info_file('RHEV')
dsrc = DataSourceAltCloud({}, None, self.paths)
dsrc.user_data_rhevm = lambda: False
- self.assertEquals(False, dsrc.get_data())
+ self.assertEqual(False, dsrc.get_data())
def test_fail_vsphere(self):
'''Failure Test module get_data() forcing VSPHERE.'''
@@ -211,14 +211,14 @@ class TestGetDataCloudInfoFile(TestCase):
_write_cloud_info_file('VSPHERE')
dsrc = DataSourceAltCloud({}, None, self.paths)
dsrc.user_data_vsphere = lambda: False
- self.assertEquals(False, dsrc.get_data())
+ self.assertEqual(False, dsrc.get_data())
def test_unrecognized(self):
'''Failure Test module get_data() forcing unrecognized.'''
_write_cloud_info_file('unrecognized')
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.get_data())
+ self.assertEqual(False, dsrc.get_data())
class TestGetDataNoCloudInfoFile(TestCase):
@@ -250,7 +250,7 @@ class TestGetDataNoCloudInfoFile(TestCase):
util.read_dmi_data = _dmi_data('RHEV Hypervisor')
dsrc = DataSourceAltCloud({}, None, self.paths)
dsrc.user_data_rhevm = lambda: True
- self.assertEquals(True, dsrc.get_data())
+ self.assertEqual(True, dsrc.get_data())
def test_vsphere_no_cloud_file(self):
'''Test No cloud info file module get_data() forcing VSPHERE.'''
@@ -258,14 +258,14 @@ class TestGetDataNoCloudInfoFile(TestCase):
util.read_dmi_data = _dmi_data('VMware Virtual Platform')
dsrc = DataSourceAltCloud({}, None, self.paths)
dsrc.user_data_vsphere = lambda: True
- self.assertEquals(True, dsrc.get_data())
+ self.assertEqual(True, dsrc.get_data())
def test_failure_no_cloud_file(self):
'''Test No cloud info file module get_data() forcing unrecognized.'''
util.read_dmi_data = _dmi_data('Unrecognized Platform')
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.get_data())
+ self.assertEqual(False, dsrc.get_data())
class TestUserDataRhevm(TestCase):
@@ -305,7 +305,7 @@ class TestUserDataRhevm(TestCase):
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.user_data_rhevm())
+ self.assertEqual(False, dsrc.user_data_rhevm())
def test_modprobe_fails(self):
'''Test user_data_rhevm() where modprobe fails.'''
@@ -315,7 +315,7 @@ class TestUserDataRhevm(TestCase):
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.user_data_rhevm())
+ self.assertEqual(False, dsrc.user_data_rhevm())
def test_no_modprobe_cmd(self):
'''Test user_data_rhevm() with no modprobe command.'''
@@ -325,7 +325,7 @@ class TestUserDataRhevm(TestCase):
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.user_data_rhevm())
+ self.assertEqual(False, dsrc.user_data_rhevm())
def test_udevadm_fails(self):
'''Test user_data_rhevm() where udevadm fails.'''
@@ -335,7 +335,7 @@ class TestUserDataRhevm(TestCase):
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.user_data_rhevm())
+ self.assertEqual(False, dsrc.user_data_rhevm())
def test_no_udevadm_cmd(self):
'''Test user_data_rhevm() with no udevadm command.'''
@@ -345,7 +345,7 @@ class TestUserDataRhevm(TestCase):
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.user_data_rhevm())
+ self.assertEqual(False, dsrc.user_data_rhevm())
class TestUserDataVsphere(TestCase):
@@ -380,7 +380,7 @@ class TestUserDataVsphere(TestCase):
dsrc = DataSourceAltCloud({}, None, self.paths)
- self.assertEquals(False, dsrc.user_data_vsphere())
+ self.assertEqual(False, dsrc.user_data_vsphere())
class TestReadUserDataCallback(TestCase):
@@ -408,8 +408,8 @@ class TestReadUserDataCallback(TestCase):
def test_callback_both(self):
'''Test read_user_data_callback() with both files.'''
- self.assertEquals('test user data',
- read_user_data_callback(self.mount_dir))
+ self.assertEqual('test user data',
+ read_user_data_callback(self.mount_dir))
def test_callback_dc(self):
'''Test read_user_data_callback() with only DC file.'''
@@ -418,8 +418,8 @@ class TestReadUserDataCallback(TestCase):
dc_file=False,
non_dc_file=True)
- self.assertEquals('test user data',
- read_user_data_callback(self.mount_dir))
+ self.assertEqual('test user data',
+ read_user_data_callback(self.mount_dir))
def test_callback_non_dc(self):
'''Test read_user_data_callback() with only non-DC file.'''
@@ -428,14 +428,14 @@ class TestReadUserDataCallback(TestCase):
dc_file=True,
non_dc_file=False)
- self.assertEquals('test user data',
- read_user_data_callback(self.mount_dir))
+ self.assertEqual('test user data',
+ read_user_data_callback(self.mount_dir))
def test_callback_none(self):
'''Test read_user_data_callback() no files are found.'''
_remove_user_data_files(self.mount_dir)
- self.assertEquals(None, read_user_data_callback(self.mount_dir))
+ self.assertEqual(None, read_user_data_callback(self.mount_dir))
def force_arch(arch=None):
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index 444e2799..5f3eb31f 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -14,11 +14,11 @@ except ImportError:
import crypt
import os
-import stat
-import yaml
import shutil
+import stat
import tempfile
import xml.etree.ElementTree as ET
+import yaml
def construct_valid_ovf_env(data=None, pubkeys=None, userdata=None):
@@ -165,7 +165,7 @@ class TestAzureDataSource(TestCase):
def tags_equal(x, y):
for x_tag, x_val in x.items():
y_val = y.get(x_val.tag)
- self.assertEquals(x_val.text, y_val.text)
+ self.assertEqual(x_val.text, y_val.text)
old_cnt = create_tag_index(oxml)
new_cnt = create_tag_index(nxml)
@@ -354,8 +354,8 @@ class TestAzureDataSource(TestCase):
self.assertTrue(ret)
cfg = dsrc.get_config_obj()
- self.assertEquals(dsrc.device_name_to_device("ephemeral0"),
- "/dev/sdb")
+ self.assertEqual(dsrc.device_name_to_device("ephemeral0"),
+ "/dev/sdb")
assert 'disk_setup' in cfg
assert 'fs_setup' in cfg
self.assertIsInstance(cfg['disk_setup'], dict)
@@ -404,15 +404,15 @@ class TestAzureDataSource(TestCase):
self.xml_notequals(data['ovfcontent'], on_disk_ovf)
# Make sure that the redacted password on disk is not used by CI
- self.assertNotEquals(dsrc.cfg.get('password'),
- DataSourceAzure.DEF_PASSWD_REDACTION)
+ self.assertNotEqual(dsrc.cfg.get('password'),
+ DataSourceAzure.DEF_PASSWD_REDACTION)
# Make sure that the password was really encrypted
et = ET.fromstring(on_disk_ovf)
for elem in et.iter():
if 'UserPassword' in elem.tag:
- self.assertEquals(DataSourceAzure.DEF_PASSWD_REDACTION,
- elem.text)
+ self.assertEqual(DataSourceAzure.DEF_PASSWD_REDACTION,
+ elem.text)
def test_ovf_env_arrives_in_waagent_dir(self):
xml = construct_valid_ovf_env(data={}, userdata="FOODATA")
diff --git a/tests/unittests/test_datasource/test_azure_helper.py b/tests/unittests/test_datasource/test_azure_helper.py
index 1134199b..921bc978 100644
--- a/tests/unittests/test_datasource/test_azure_helper.py
+++ b/tests/unittests/test_datasource/test_azure_helper.py
@@ -1,6 +1,7 @@
import os
from cloudinit.sources.helpers import azure as azure_helper
+
from ..helpers import TestCase
try:
diff --git a/tests/unittests/test_datasource/test_cloudstack.py b/tests/unittests/test_datasource/test_cloudstack.py
index 656d80d1..974b3704 100644
--- a/tests/unittests/test_datasource/test_cloudstack.py
+++ b/tests/unittests/test_datasource/test_cloudstack.py
@@ -1,5 +1,6 @@
from cloudinit import helpers
from cloudinit.sources.DataSourceCloudStack import DataSourceCloudStack
+
from ..helpers import TestCase
try:
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
index 89b15f54..195b8207 100644
--- a/tests/unittests/test_datasource/test_configdrive.py
+++ b/tests/unittests/test_datasource/test_configdrive.py
@@ -151,7 +151,7 @@ class TestConfigDriveDataSource(TestCase):
mock.patch.object(os.path, 'exists',
side_effect=exists_side_effect()))
device = cfg_ds.device_name_to_device(name)
- self.assertEquals(dev_name, device)
+ self.assertEqual(dev_name, device)
find_mock.assert_called_once_with(mock.ANY)
self.assertEqual(exists_mock.call_count, 2)
@@ -179,7 +179,7 @@ class TestConfigDriveDataSource(TestCase):
mock.patch.object(os.path, 'exists',
return_value=True))
device = cfg_ds.device_name_to_device(name)
- self.assertEquals(dev_name, device)
+ self.assertEqual(dev_name, device)
find_mock.assert_called_once_with(mock.ANY)
exists_mock.assert_called_once_with(mock.ANY)
@@ -214,7 +214,7 @@ class TestConfigDriveDataSource(TestCase):
with mock.patch.object(os.path, 'exists',
side_effect=exists_side_effect()):
device = cfg_ds.device_name_to_device(name)
- self.assertEquals(dev_name, device)
+ self.assertEqual(dev_name, device)
# We don't assert the call count for os.path.exists() because
# not all of the entries in name_tests results in two calls to
# that function. Specifically, 'root2k' doesn't seem to call
@@ -242,7 +242,7 @@ class TestConfigDriveDataSource(TestCase):
for name, dev_name in name_tests.items():
with mock.patch.object(os.path, 'exists', return_value=True):
device = cfg_ds.device_name_to_device(name)
- self.assertEquals(dev_name, device)
+ self.assertEqual(dev_name, device)
def test_dir_valid(self):
"""Verify a dir is read as such."""
diff --git a/tests/unittests/test_datasource/test_digitalocean.py b/tests/unittests/test_datasource/test_digitalocean.py
index 679d1b82..8936a1e3 100644
--- a/tests/unittests/test_datasource/test_digitalocean.py
+++ b/tests/unittests/test_datasource/test_digitalocean.py
@@ -19,8 +19,8 @@ import re
from six.moves.urllib_parse import urlparse
-from cloudinit import settings
from cloudinit import helpers
+from cloudinit import settings
from cloudinit.sources import DataSourceDigitalOcean
from .. import helpers as test_helpers
diff --git a/tests/unittests/test_datasource/test_gce.py b/tests/unittests/test_datasource/test_gce.py
index fa714070..1f7eb99e 100644
--- a/tests/unittests/test_datasource/test_gce.py
+++ b/tests/unittests/test_datasource/test_gce.py
@@ -20,8 +20,8 @@ import re
from base64 import b64encode, b64decode
from six.moves.urllib_parse import urlparse
-from cloudinit import settings
from cloudinit import helpers
+from cloudinit import settings
from cloudinit.sources import DataSourceGCE
from .. import helpers as test_helpers
diff --git a/tests/unittests/test_datasource/test_maas.py b/tests/unittests/test_datasource/test_maas.py
index 77d15cac..f66f1c6d 100644
--- a/tests/unittests/test_datasource/test_maas.py
+++ b/tests/unittests/test_datasource/test_maas.py
@@ -104,13 +104,13 @@ class TestMAASDataSource(TestCase):
'meta-data/local-hostname': 'test-hostname',
'meta-data/public-keys': 'test-hostname',
'user-data': b'foodata',
- }
+ }
valid_order = [
'meta-data/local-hostname',
'meta-data/instance-id',
'meta-data/public-keys',
'user-data',
- ]
+ ]
my_seed = "http://example.com/xmeta"
my_ver = "1999-99-99"
my_headers = {'header1': 'value1', 'header2': 'value2'}
diff --git a/tests/unittests/test_datasource/test_nocloud.py b/tests/unittests/test_datasource/test_nocloud.py
index 2d5fc37c..3c528c23 100644
--- a/tests/unittests/test_datasource/test_nocloud.py
+++ b/tests/unittests/test_datasource/test_nocloud.py
@@ -4,10 +4,10 @@ from cloudinit import util
from ..helpers import TestCase, populate_dir
import os
-import yaml
import shutil
import tempfile
import unittest
+import yaml
try:
from unittest import mock
diff --git a/tests/unittests/test_datasource/test_openstack.py b/tests/unittests/test_datasource/test_openstack.py
index 0aa1ba84..4140d054 100644
--- a/tests/unittests/test_datasource/test_openstack.py
+++ b/tests/unittests/test_datasource/test_openstack.py
@@ -22,8 +22,8 @@ import re
from .. import helpers as test_helpers
-from six import StringIO
from six.moves.urllib.parse import urlparse
+from six import StringIO
from cloudinit import helpers
from cloudinit import settings
@@ -142,34 +142,34 @@ class TestOpenStackDataSource(test_helpers.HttprettyTestCase):
def test_successful(self):
_register_uris(self.VERSION, EC2_FILES, EC2_META, OS_FILES)
f = ds.read_metadata_service(BASE_URL)
- self.assertEquals(VENDOR_DATA, f.get('vendordata'))
- self.assertEquals(CONTENT_0, f['files']['/etc/foo.cfg'])
- self.assertEquals(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
- self.assertEquals(2, len(f['files']))
- self.assertEquals(USER_DATA, f.get('userdata'))
- self.assertEquals(EC2_META, f.get('ec2-metadata'))
- self.assertEquals(2, f.get('version'))
+ self.assertEqual(VENDOR_DATA, f.get('vendordata'))
+ self.assertEqual(CONTENT_0, f['files']['/etc/foo.cfg'])
+ self.assertEqual(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
+ self.assertEqual(2, len(f['files']))
+ self.assertEqual(USER_DATA, f.get('userdata'))
+ self.assertEqual(EC2_META, f.get('ec2-metadata'))
+ self.assertEqual(2, f.get('version'))
metadata = f['metadata']
- self.assertEquals('nova', metadata.get('availability_zone'))
- self.assertEquals('sm-foo-test.novalocal', metadata.get('hostname'))
- self.assertEquals('sm-foo-test.novalocal',
- metadata.get('local-hostname'))
- self.assertEquals('sm-foo-test', metadata.get('name'))
- self.assertEquals('b0fa911b-69d4-4476-bbe2-1c92bff6535c',
- metadata.get('uuid'))
- self.assertEquals('b0fa911b-69d4-4476-bbe2-1c92bff6535c',
- metadata.get('instance-id'))
+ self.assertEqual('nova', metadata.get('availability_zone'))
+ self.assertEqual('sm-foo-test.novalocal', metadata.get('hostname'))
+ self.assertEqual('sm-foo-test.novalocal',
+ metadata.get('local-hostname'))
+ self.assertEqual('sm-foo-test', metadata.get('name'))
+ self.assertEqual('b0fa911b-69d4-4476-bbe2-1c92bff6535c',
+ metadata.get('uuid'))
+ self.assertEqual('b0fa911b-69d4-4476-bbe2-1c92bff6535c',
+ metadata.get('instance-id'))
@hp.activate
def test_no_ec2(self):
_register_uris(self.VERSION, {}, {}, OS_FILES)
f = ds.read_metadata_service(BASE_URL)
- self.assertEquals(VENDOR_DATA, f.get('vendordata'))
- self.assertEquals(CONTENT_0, f['files']['/etc/foo.cfg'])
- self.assertEquals(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
- self.assertEquals(USER_DATA, f.get('userdata'))
- self.assertEquals({}, f.get('ec2-metadata'))
- self.assertEquals(2, f.get('version'))
+ self.assertEqual(VENDOR_DATA, f.get('vendordata'))
+ self.assertEqual(CONTENT_0, f['files']['/etc/foo.cfg'])
+ self.assertEqual(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
+ self.assertEqual(USER_DATA, f.get('userdata'))
+ self.assertEqual({}, f.get('ec2-metadata'))
+ self.assertEqual(2, f.get('version'))
@hp.activate
def test_bad_metadata(self):
@@ -201,9 +201,9 @@ class TestOpenStackDataSource(test_helpers.HttprettyTestCase):
os_files.pop(k, None)
_register_uris(self.VERSION, {}, {}, os_files)
f = ds.read_metadata_service(BASE_URL)
- self.assertEquals(VENDOR_DATA, f.get('vendordata'))
- self.assertEquals(CONTENT_0, f['files']['/etc/foo.cfg'])
- self.assertEquals(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
+ self.assertEqual(VENDOR_DATA, f.get('vendordata'))
+ self.assertEqual(CONTENT_0, f['files']['/etc/foo.cfg'])
+ self.assertEqual(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
self.assertFalse(f.get('userdata'))
@hp.activate
@@ -214,8 +214,8 @@ class TestOpenStackDataSource(test_helpers.HttprettyTestCase):
os_files.pop(k, None)
_register_uris(self.VERSION, {}, {}, os_files)
f = ds.read_metadata_service(BASE_URL)
- self.assertEquals(CONTENT_0, f['files']['/etc/foo.cfg'])
- self.assertEquals(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
+ self.assertEqual(CONTENT_0, f['files']['/etc/foo.cfg'])
+ self.assertEqual(CONTENT_1, f['files']['/etc/bar/bar.cfg'])
self.assertFalse(f.get('vendordata'))
@hp.activate
@@ -247,16 +247,16 @@ class TestOpenStackDataSource(test_helpers.HttprettyTestCase):
self.assertIsNone(ds_os.version)
found = ds_os.get_data()
self.assertTrue(found)
- self.assertEquals(2, ds_os.version)
+ self.assertEqual(2, ds_os.version)
md = dict(ds_os.metadata)
md.pop('instance-id', None)
md.pop('local-hostname', None)
- self.assertEquals(OSTACK_META, md)
- self.assertEquals(EC2_META, ds_os.ec2_metadata)
- self.assertEquals(USER_DATA, ds_os.userdata_raw)
- self.assertEquals(2, len(ds_os.files))
- self.assertEquals(VENDOR_DATA, ds_os.vendordata_pure)
- self.assertEquals(ds_os.vendordata_raw, None)
+ self.assertEqual(OSTACK_META, md)
+ self.assertEqual(EC2_META, ds_os.ec2_metadata)
+ self.assertEqual(USER_DATA, ds_os.userdata_raw)
+ self.assertEqual(2, len(ds_os.files))
+ self.assertEqual(VENDOR_DATA, ds_os.vendordata_pure)
+ self.assertEqual(ds_os.vendordata_raw, None)
@hp.activate
def test_bad_datasource_meta(self):
diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py
index 5c49966a..cdd04a72 100644
--- a/tests/unittests/test_datasource/test_smartos.py
+++ b/tests/unittests/test_datasource/test_smartos.py
@@ -24,6 +24,7 @@
from __future__ import print_function
+from binascii import crc32
import os
import os.path
import re
@@ -31,7 +32,6 @@ import shutil
import stat
import tempfile
import uuid
-from binascii import crc32
import serial
import six
@@ -157,16 +157,16 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds()
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals('kvm', dsrc.smartos_type)
- self.assertEquals('/dev/ttyS1', dsrc.seed)
+ self.assertEqual('kvm', dsrc.smartos_type)
+ self.assertEqual('/dev/ttyS1', dsrc.seed)
def test_seed_lxbrand(self):
# default seed should be /dev/ttyS1
dsrc = self._get_ds(is_lxbrand=True)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals('lx-brand', dsrc.smartos_type)
- self.assertEquals('/native/.zonecontrol/metadata.sock', dsrc.seed)
+ self.assertEqual('lx-brand', dsrc.smartos_type)
+ self.assertEqual('/native/.zonecontrol/metadata.sock', dsrc.seed)
def test_issmartdc(self):
dsrc = self._get_ds()
@@ -190,29 +190,29 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['sdc:uuid'],
- dsrc.metadata['instance-id'])
+ self.assertEqual(MOCK_RETURNS['sdc:uuid'],
+ dsrc.metadata['instance-id'])
def test_root_keys(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['root_authorized_keys'],
- dsrc.metadata['public-keys'])
+ self.assertEqual(MOCK_RETURNS['root_authorized_keys'],
+ dsrc.metadata['public-keys'])
def test_hostname_b64(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['hostname'],
- dsrc.metadata['local-hostname'])
+ self.assertEqual(MOCK_RETURNS['hostname'],
+ dsrc.metadata['local-hostname'])
def test_hostname(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['hostname'],
- dsrc.metadata['local-hostname'])
+ self.assertEqual(MOCK_RETURNS['hostname'],
+ dsrc.metadata['local-hostname'])
def test_base64_all(self):
# metadata provided base64_all of true
@@ -224,16 +224,16 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=my_returns)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['hostname'],
- dsrc.metadata['local-hostname'])
- self.assertEquals(MOCK_RETURNS['cloud-init:user-data'],
- dsrc.userdata_raw)
- self.assertEquals(MOCK_RETURNS['root_authorized_keys'],
- dsrc.metadata['public-keys'])
- self.assertEquals(MOCK_RETURNS['disable_iptables_flag'],
- dsrc.metadata['iptables_disable'])
- self.assertEquals(MOCK_RETURNS['enable_motd_sys_info'],
- dsrc.metadata['motd_sys_info'])
+ self.assertEqual(MOCK_RETURNS['hostname'],
+ dsrc.metadata['local-hostname'])
+ self.assertEqual(MOCK_RETURNS['cloud-init:user-data'],
+ dsrc.userdata_raw)
+ self.assertEqual(MOCK_RETURNS['root_authorized_keys'],
+ dsrc.metadata['public-keys'])
+ self.assertEqual(MOCK_RETURNS['disable_iptables_flag'],
+ dsrc.metadata['iptables_disable'])
+ self.assertEqual(MOCK_RETURNS['enable_motd_sys_info'],
+ dsrc.metadata['motd_sys_info'])
def test_b64_userdata(self):
my_returns = MOCK_RETURNS.copy()
@@ -245,12 +245,12 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=my_returns)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['hostname'],
- dsrc.metadata['local-hostname'])
- self.assertEquals(MOCK_RETURNS['cloud-init:user-data'],
- dsrc.userdata_raw)
- self.assertEquals(MOCK_RETURNS['root_authorized_keys'],
- dsrc.metadata['public-keys'])
+ self.assertEqual(MOCK_RETURNS['hostname'],
+ dsrc.metadata['local-hostname'])
+ self.assertEqual(MOCK_RETURNS['cloud-init:user-data'],
+ dsrc.userdata_raw)
+ self.assertEqual(MOCK_RETURNS['root_authorized_keys'],
+ dsrc.metadata['public-keys'])
def test_b64_keys(self):
my_returns = MOCK_RETURNS.copy()
@@ -261,39 +261,39 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=my_returns)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['hostname'],
- dsrc.metadata['local-hostname'])
- self.assertEquals(MOCK_RETURNS['cloud-init:user-data'],
- dsrc.userdata_raw)
+ self.assertEqual(MOCK_RETURNS['hostname'],
+ dsrc.metadata['local-hostname'])
+ self.assertEqual(MOCK_RETURNS['cloud-init:user-data'],
+ dsrc.userdata_raw)
def test_userdata(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['user-data'],
- dsrc.metadata['legacy-user-data'])
- self.assertEquals(MOCK_RETURNS['cloud-init:user-data'],
- dsrc.userdata_raw)
+ self.assertEqual(MOCK_RETURNS['user-data'],
+ dsrc.metadata['legacy-user-data'])
+ self.assertEqual(MOCK_RETURNS['cloud-init:user-data'],
+ dsrc.userdata_raw)
def test_sdc_scripts(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['user-script'],
- dsrc.metadata['user-script'])
+ self.assertEqual(MOCK_RETURNS['user-script'],
+ dsrc.metadata['user-script'])
legacy_script_f = "%s/user-script" % self.legacy_user_d
self.assertTrue(os.path.exists(legacy_script_f))
self.assertTrue(os.path.islink(legacy_script_f))
user_script_perm = oct(os.stat(legacy_script_f)[stat.ST_MODE])[-3:]
- self.assertEquals(user_script_perm, '700')
+ self.assertEqual(user_script_perm, '700')
def test_scripts_shebanged(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['user-script'],
- dsrc.metadata['user-script'])
+ self.assertEqual(MOCK_RETURNS['user-script'],
+ dsrc.metadata['user-script'])
legacy_script_f = "%s/user-script" % self.legacy_user_d
self.assertTrue(os.path.exists(legacy_script_f))
@@ -301,9 +301,9 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
shebang = None
with open(legacy_script_f, 'r') as f:
shebang = f.readlines()[0].strip()
- self.assertEquals(shebang, "#!/bin/bash")
+ self.assertEqual(shebang, "#!/bin/bash")
user_script_perm = oct(os.stat(legacy_script_f)[stat.ST_MODE])[-3:]
- self.assertEquals(user_script_perm, '700')
+ self.assertEqual(user_script_perm, '700')
def test_scripts_shebang_not_added(self):
"""
@@ -319,8 +319,8 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=my_returns)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(my_returns['user-script'],
- dsrc.metadata['user-script'])
+ self.assertEqual(my_returns['user-script'],
+ dsrc.metadata['user-script'])
legacy_script_f = "%s/user-script" % self.legacy_user_d
self.assertTrue(os.path.exists(legacy_script_f))
@@ -328,7 +328,7 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
shebang = None
with open(legacy_script_f, 'r') as f:
shebang = f.readlines()[0].strip()
- self.assertEquals(shebang, "#!/usr/bin/perl")
+ self.assertEqual(shebang, "#!/usr/bin/perl")
def test_userdata_removed(self):
"""
@@ -358,7 +358,7 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
if re.match(r'.*\/mdata-user-data$', name_f):
found_new = True
print(name_f)
- self.assertEquals(permissions, '400')
+ self.assertEqual(permissions, '400')
self.assertFalse(found_new)
@@ -366,8 +366,8 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['sdc:vendor-data'],
- dsrc.metadata['vendor-data'])
+ self.assertEqual(MOCK_RETURNS['sdc:vendor-data'],
+ dsrc.metadata['vendor-data'])
def test_default_vendor_data(self):
my_returns = MOCK_RETURNS.copy()
@@ -376,7 +376,7 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=my_returns)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertNotEquals(def_op_script, dsrc.metadata['vendor-data'])
+ self.assertNotEqual(def_op_script, dsrc.metadata['vendor-data'])
# we expect default vendor-data is a boothook
self.assertTrue(dsrc.vendordata_raw.startswith("#cloud-boothook"))
@@ -385,15 +385,15 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['disable_iptables_flag'],
- dsrc.metadata['iptables_disable'])
+ self.assertEqual(MOCK_RETURNS['disable_iptables_flag'],
+ dsrc.metadata['iptables_disable'])
def test_motd_sys_info(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['enable_motd_sys_info'],
- dsrc.metadata['motd_sys_info'])
+ self.assertEqual(MOCK_RETURNS['enable_motd_sys_info'],
+ dsrc.metadata['motd_sys_info'])
def test_default_ephemeral(self):
# Test to make sure that the builtin config has the ephemeral
diff --git a/tests/unittests/test_distros/test_generic.py b/tests/unittests/test_distros/test_generic.py
index 6ed1704c..96fa0811 100644
--- a/tests/unittests/test_distros/test_generic.py
+++ b/tests/unittests/test_distros/test_generic.py
@@ -87,13 +87,13 @@ class TestGenericDistro(helpers.FilesystemMockingTestCase):
rules = 'ALL=(ALL:ALL) ALL'
contents = self._write_load_sudoers('harlowja', rules)
expected = ['harlowja ALL=(ALL:ALL) ALL']
- self.assertEquals(len(expected), self._count_in(expected, contents))
+ self.assertEqual(len(expected), self._count_in(expected, contents))
not_expected = [
'harlowja A',
'harlowja L',
'harlowja L',
]
- self.assertEquals(0, self._count_in(not_expected, contents))
+ self.assertEqual(0, self._count_in(not_expected, contents))
def test_sudoers_ensure_rules_list(self):
rules = [
@@ -107,13 +107,13 @@ class TestGenericDistro(helpers.FilesystemMockingTestCase):
'harlowja B-ALL=(ALL:ALL) ALL',
'harlowja C-ALL=(ALL:ALL) ALL',
]
- self.assertEquals(len(expected), self._count_in(expected, contents))
+ self.assertEqual(len(expected), self._count_in(expected, contents))
not_expected = [
'harlowja A',
'harlowja L',
'harlowja L',
]
- self.assertEquals(0, self._count_in(not_expected, contents))
+ self.assertEqual(0, self._count_in(not_expected, contents))
def test_sudoers_ensure_new(self):
cls = distros.fetch("ubuntu")
@@ -136,7 +136,7 @@ class TestGenericDistro(helpers.FilesystemMockingTestCase):
self.assertIn("includedir /b", contents)
self.assertTrue(os.path.isdir("/b"))
self.assertIn("josh", contents)
- self.assertEquals(2, contents.count("josh"))
+ self.assertEqual(2, contents.count("josh"))
def test_arch_package_mirror_info_unknown(self):
"""for an unknown arch, we should get back that with arch 'default'."""
diff --git a/tests/unittests/test_distros/test_hostname.py b/tests/unittests/test_distros/test_hostname.py
index 143e29a9..5f28a868 100644
--- a/tests/unittests/test_distros/test_hostname.py
+++ b/tests/unittests/test_distros/test_hostname.py
@@ -15,24 +15,24 @@ BASE_HOSTNAME = BASE_HOSTNAME.strip()
class TestHostnameHelper(unittest.TestCase):
def test_parse_same(self):
hn = hostname.HostnameConf(BASE_HOSTNAME)
- self.assertEquals(str(hn).strip(), BASE_HOSTNAME)
- self.assertEquals(hn.hostname, 'blahblah')
+ self.assertEqual(str(hn).strip(), BASE_HOSTNAME)
+ self.assertEqual(hn.hostname, 'blahblah')
def test_no_adjust_hostname(self):
hn = hostname.HostnameConf(BASE_HOSTNAME)
prev_name = hn.hostname
hn.set_hostname("")
- self.assertEquals(hn.hostname, prev_name)
+ self.assertEqual(hn.hostname, prev_name)
def test_adjust_hostname(self):
hn = hostname.HostnameConf(BASE_HOSTNAME)
prev_name = hn.hostname
- self.assertEquals(prev_name, 'blahblah')
+ self.assertEqual(prev_name, 'blahblah')
hn.set_hostname("bbbbd")
- self.assertEquals(hn.hostname, 'bbbbd')
+ self.assertEqual(hn.hostname, 'bbbbd')
expected_out = '''
# My super-duper-hostname
bbbbd
'''
- self.assertEquals(str(hn).strip(), expected_out.strip())
+ self.assertEqual(str(hn).strip(), expected_out.strip())
diff --git a/tests/unittests/test_distros/test_hosts.py b/tests/unittests/test_distros/test_hosts.py
index fc701eaa..ab867c6f 100644
--- a/tests/unittests/test_distros/test_hosts.py
+++ b/tests/unittests/test_distros/test_hosts.py
@@ -17,25 +17,25 @@ BASE_ETC = BASE_ETC.strip()
class TestHostsHelper(unittest.TestCase):
def test_parse(self):
eh = hosts.HostsConf(BASE_ETC)
- self.assertEquals(eh.get_entry('127.0.0.1'), [['localhost']])
- self.assertEquals(eh.get_entry('192.168.1.10'),
- [['foo.mydomain.org', 'foo'],
- ['bar.mydomain.org', 'bar']])
+ self.assertEqual(eh.get_entry('127.0.0.1'), [['localhost']])
+ self.assertEqual(eh.get_entry('192.168.1.10'),
+ [['foo.mydomain.org', 'foo'],
+ ['bar.mydomain.org', 'bar']])
eh = str(eh)
self.assertTrue(eh.startswith('# Example'))
def test_add(self):
eh = hosts.HostsConf(BASE_ETC)
eh.add_entry('127.0.0.0', 'blah')
- self.assertEquals(eh.get_entry('127.0.0.0'), [['blah']])
+ self.assertEqual(eh.get_entry('127.0.0.0'), [['blah']])
eh.add_entry('127.0.0.3', 'blah', 'blah2', 'blah3')
- self.assertEquals(eh.get_entry('127.0.0.3'),
- [['blah', 'blah2', 'blah3']])
+ self.assertEqual(eh.get_entry('127.0.0.3'),
+ [['blah', 'blah2', 'blah3']])
def test_del(self):
eh = hosts.HostsConf(BASE_ETC)
eh.add_entry('127.0.0.0', 'blah')
- self.assertEquals(eh.get_entry('127.0.0.0'), [['blah']])
+ self.assertEqual(eh.get_entry('127.0.0.0'), [['blah']])
eh.del_entries('127.0.0.0')
- self.assertEquals(eh.get_entry('127.0.0.0'), [])
+ self.assertEqual(eh.get_entry('127.0.0.0'), [])
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
index 2c2a424d..9172e3aa 100644
--- a/tests/unittests/test_distros/test_netconfig.py
+++ b/tests/unittests/test_distros/test_netconfig.py
@@ -1,4 +1,5 @@
import os
+from six import StringIO
try:
from unittest import mock
@@ -9,16 +10,14 @@ try:
except ImportError:
from contextlib2 import ExitStack
-from six import StringIO
from ..helpers import TestCase
from cloudinit import distros
+from cloudinit.distros.parsers.sys_conf import SysConf
from cloudinit import helpers
from cloudinit import settings
from cloudinit import util
-from cloudinit.distros.parsers.sys_conf import SysConf
-
BASE_NET_CFG = '''
auto lo
@@ -108,23 +107,23 @@ class TestNetCfgDistro(TestCase):
ub_distro.apply_network(BASE_NET_CFG, False)
- self.assertEquals(len(write_bufs), 1)
+ self.assertEqual(len(write_bufs), 1)
eni_name = '/etc/network/interfaces.d/50-cloud-init.cfg'
self.assertIn(eni_name, write_bufs)
write_buf = write_bufs[eni_name]
- self.assertEquals(str(write_buf).strip(), BASE_NET_CFG.strip())
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(str(write_buf).strip(), BASE_NET_CFG.strip())
+ self.assertEqual(write_buf.mode, 0o644)
def assertCfgEquals(self, blob1, blob2):
b1 = dict(SysConf(blob1.strip().splitlines()))
b2 = dict(SysConf(blob2.strip().splitlines()))
- self.assertEquals(b1, b2)
+ self.assertEqual(b1, b2)
for (k, v) in b1.items():
self.assertIn(k, b2)
for (k, v) in b2.items():
self.assertIn(k, b1)
for (k, v) in b1.items():
- self.assertEquals(v, b2[k])
+ self.assertEqual(v, b2[k])
def test_simple_write_rh(self):
rh_distro = self._get_distro('rhel')
@@ -148,7 +147,7 @@ class TestNetCfgDistro(TestCase):
rh_distro.apply_network(BASE_NET_CFG, False)
- self.assertEquals(len(write_bufs), 4)
+ self.assertEqual(len(write_bufs), 4)
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-lo',
write_bufs)
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-lo']
@@ -157,7 +156,7 @@ DEVICE="lo"
ONBOOT=yes
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth0',
write_bufs)
@@ -172,7 +171,7 @@ GATEWAY="192.168.1.254"
BROADCAST="192.168.1.0"
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth1',
write_bufs)
@@ -183,7 +182,7 @@ BOOTPROTO="dhcp"
ONBOOT=yes
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
self.assertIn('/etc/sysconfig/network', write_bufs)
write_buf = write_bufs['/etc/sysconfig/network']
@@ -192,7 +191,7 @@ ONBOOT=yes
NETWORKING=yes
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
def test_write_ipv6_rhel(self):
rh_distro = self._get_distro('rhel')
@@ -216,7 +215,7 @@ NETWORKING=yes
rh_distro.apply_network(BASE_NET_CFG_IPV6, False)
- self.assertEquals(len(write_bufs), 4)
+ self.assertEqual(len(write_bufs), 4)
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-lo',
write_bufs)
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-lo']
@@ -225,7 +224,7 @@ DEVICE="lo"
ONBOOT=yes
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth0',
write_bufs)
@@ -243,7 +242,7 @@ IPV6ADDR="2607:f0d0:1002:0011::2"
IPV6_DEFAULTGW="2607:f0d0:1002:0011::1"
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth1',
write_bufs)
write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth1']
@@ -260,7 +259,7 @@ IPV6ADDR="2607:f0d0:1002:0011::3"
IPV6_DEFAULTGW="2607:f0d0:1002:0011::1"
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
self.assertIn('/etc/sysconfig/network', write_bufs)
write_buf = write_bufs['/etc/sysconfig/network']
@@ -271,7 +270,7 @@ NETWORKING_IPV6=yes
IPV6_AUTOCONF=no
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
def test_simple_write_freebsd(self):
fbsd_distro = self._get_distro('freebsd')
@@ -319,4 +318,4 @@ ifconfig_vtnet1="DHCP"
defaultrouter="192.168.1.254"
'''
self.assertCfgEquals(expected_buf, str(write_buf))
- self.assertEquals(write_buf.mode, 0o644)
+ self.assertEqual(write_buf.mode, 0o644)
diff --git a/tests/unittests/test_distros/test_resolv.py b/tests/unittests/test_distros/test_resolv.py
index 9edeb6e7..9402b5ea 100644
--- a/tests/unittests/test_distros/test_resolv.py
+++ b/tests/unittests/test_distros/test_resolv.py
@@ -1,9 +1,10 @@
from cloudinit.distros.parsers import resolv_conf
from cloudinit.distros import rhel_util
+from ..helpers import TestCase
+
import re
import tempfile
-from ..helpers import TestCase
BASE_RESOLVE = '''
@@ -19,7 +20,7 @@ class TestResolvHelper(TestCase):
def test_parse_same(self):
rp = resolv_conf.ResolvConf(BASE_RESOLVE)
rp_r = str(rp).strip()
- self.assertEquals(BASE_RESOLVE, rp_r)
+ self.assertEqual(BASE_RESOLVE, rp_r)
def test_write_works(self):
with tempfile.NamedTemporaryFile() as fh:
@@ -27,10 +28,10 @@ class TestResolvHelper(TestCase):
def test_local_domain(self):
rp = resolv_conf.ResolvConf(BASE_RESOLVE)
- self.assertEquals(None, rp.local_domain)
+ self.assertEqual(None, rp.local_domain)
rp.local_domain = "bob"
- self.assertEquals('bob', rp.local_domain)
+ self.assertEqual('bob', rp.local_domain)
self.assertIn('domain bob', str(rp))
def test_nameservers(self):
@@ -41,7 +42,7 @@ class TestResolvHelper(TestCase):
self.assertIn('10.2', rp.nameservers)
self.assertIn('nameserver 10.2', str(rp))
self.assertNotIn('10.3', rp.nameservers)
- self.assertEquals(len(rp.nameservers), 3)
+ self.assertEqual(len(rp.nameservers), 3)
rp.add_nameserver('10.2')
self.assertRaises(ValueError, rp.add_nameserver, '10.3')
self.assertNotIn('10.3', rp.nameservers)
@@ -55,12 +56,12 @@ class TestResolvHelper(TestCase):
self.assertTrue(re.search(r'search(.*)bbb.y.com(.*)', str(rp)))
self.assertIn('bbb.y.com', rp.search_domains)
rp.add_search_domain('bbb.y.com')
- self.assertEquals(len(rp.search_domains), 3)
+ self.assertEqual(len(rp.search_domains), 3)
rp.add_search_domain('bbb2.y.com')
- self.assertEquals(len(rp.search_domains), 4)
+ self.assertEqual(len(rp.search_domains), 4)
rp.add_search_domain('bbb3.y.com')
- self.assertEquals(len(rp.search_domains), 5)
+ self.assertEqual(len(rp.search_domains), 5)
rp.add_search_domain('bbb4.y.com')
- self.assertEquals(len(rp.search_domains), 6)
+ self.assertEqual(len(rp.search_domains), 6)
self.assertRaises(ValueError, rp.add_search_domain, 'bbb5.y.com')
- self.assertEquals(len(rp.search_domains), 6)
+ self.assertEqual(len(rp.search_domains), 6)
diff --git a/tests/unittests/test_distros/test_sysconfig.py b/tests/unittests/test_distros/test_sysconfig.py
index 03d89a10..8cb55522 100644
--- a/tests/unittests/test_distros/test_sysconfig.py
+++ b/tests/unittests/test_distros/test_sysconfig.py
@@ -1,6 +1,7 @@
import re
from cloudinit.distros.parsers.sys_conf import SysConf
+
from ..helpers import TestCase
@@ -27,34 +28,34 @@ IPV6TO4_ROUTING='eth0-:0004::1/64 eth1-:0005::1/64'
ETHTOOL_OPTS="-K ${DEVICE} tso on; -G ${DEVICE} rx 256 tx 256"
USEMD5=no'''
conf = SysConf(contents.splitlines())
- self.assertEquals(conf['HOSTNAME'], 'blahblah')
- self.assertEquals(conf['SHORTDATE'], '$(date +%y:%m:%d:%H:%M)')
+ self.assertEqual(conf['HOSTNAME'], 'blahblah')
+ self.assertEqual(conf['SHORTDATE'], '$(date +%y:%m:%d:%H:%M)')
# Should be unquoted
- self.assertEquals(conf['ETHTOOL_OPTS'], ('-K ${DEVICE} tso on; '
- '-G ${DEVICE} rx 256 tx 256'))
- self.assertEquals(contents, str(conf))
+ self.assertEqual(conf['ETHTOOL_OPTS'], ('-K ${DEVICE} tso on; '
+ '-G ${DEVICE} rx 256 tx 256'))
+ self.assertEqual(contents, str(conf))
def test_parse_shell_vars(self):
contents = 'USESMBAUTH=$XYZ'
conf = SysConf(contents.splitlines())
- self.assertEquals(contents, str(conf))
+ self.assertEqual(contents, str(conf))
conf = SysConf('')
conf['B'] = '${ZZ}d apples'
# Should be quoted
- self.assertEquals('B="${ZZ}d apples"', str(conf))
+ self.assertEqual('B="${ZZ}d apples"', str(conf))
conf = SysConf('')
conf['B'] = '$? d apples'
- self.assertEquals('B="$? d apples"', str(conf))
+ self.assertEqual('B="$? d apples"', str(conf))
contents = 'IPMI_WATCHDOG_OPTIONS="timeout=60"'
conf = SysConf(contents.splitlines())
- self.assertEquals('IPMI_WATCHDOG_OPTIONS=timeout=60', str(conf))
+ self.assertEqual('IPMI_WATCHDOG_OPTIONS=timeout=60', str(conf))
def test_parse_adjust(self):
contents = 'IPV6TO4_ROUTING="eth0-:0004::1/64 eth1-:0005::1/64"'
conf = SysConf(contents.splitlines())
# Should be unquoted
- self.assertEquals('eth0-:0004::1/64 eth1-:0005::1/64',
- conf['IPV6TO4_ROUTING'])
+ self.assertEqual('eth0-:0004::1/64 eth1-:0005::1/64',
+ conf['IPV6TO4_ROUTING'])
conf['IPV6TO4_ROUTING'] = "blah \tblah"
contents2 = str(conf).strip()
# Should be requoted due to whitespace
@@ -65,12 +66,12 @@ USEMD5=no'''
conf = SysConf(''.splitlines())
conf['B'] = ' $(time)'
contents = str(conf)
- self.assertEquals('B= $(time)', contents)
+ self.assertEqual('B= $(time)', contents)
def test_parse_empty(self):
contents = ''
conf = SysConf(contents.splitlines())
- self.assertEquals('', str(conf).strip())
+ self.assertEqual('', str(conf).strip())
def test_parse_add_new(self):
contents = 'BLAH=b'
diff --git a/tests/unittests/test_distros/test_user_data_normalize.py b/tests/unittests/test_distros/test_user_data_normalize.py
index 4525f487..a887a930 100644
--- a/tests/unittests/test_distros/test_user_data_normalize.py
+++ b/tests/unittests/test_distros/test_user_data_normalize.py
@@ -33,20 +33,19 @@ class TestUGNormalize(TestCase):
def test_group_dict(self):
distro = self._make_distro('ubuntu')
- g = {'groups': [
- {'ubuntu': ['foo', 'bar'],
- 'bob': 'users'},
- 'cloud-users',
- {'bob': 'users2'}
- ]}
+ g = {'groups':
+ [{'ubuntu': ['foo', 'bar'],
+ 'bob': 'users'},
+ 'cloud-users',
+ {'bob': 'users2'}]}
(_users, groups) = self._norm(g, distro)
self.assertIn('ubuntu', groups)
ub_members = groups['ubuntu']
- self.assertEquals(sorted(['foo', 'bar']), sorted(ub_members))
+ self.assertEqual(sorted(['foo', 'bar']), sorted(ub_members))
self.assertIn('bob', groups)
b_members = groups['bob']
- self.assertEquals(sorted(['users', 'users2']),
- sorted(b_members))
+ self.assertEqual(sorted(['users', 'users2']),
+ sorted(b_members))
def test_basic_groups(self):
distro = self._make_distro('ubuntu')
@@ -55,7 +54,7 @@ class TestUGNormalize(TestCase):
}
(users, groups) = self._norm(ug_cfg, distro)
self.assertIn('bob', groups)
- self.assertEquals({}, users)
+ self.assertEqual({}, users)
def test_csv_groups(self):
distro = self._make_distro('ubuntu')
@@ -66,7 +65,7 @@ class TestUGNormalize(TestCase):
self.assertIn('bob', groups)
self.assertIn('joe', groups)
self.assertIn('steve', groups)
- self.assertEquals({}, users)
+ self.assertEqual({}, users)
def test_more_groups(self):
distro = self._make_distro('ubuntu')
@@ -77,7 +76,7 @@ class TestUGNormalize(TestCase):
self.assertIn('bob', groups)
self.assertIn('joe', groups)
self.assertIn('steve', groups)
- self.assertEquals({}, users)
+ self.assertEqual({}, users)
def test_member_groups(self):
distro = self._make_distro('ubuntu')
@@ -90,11 +89,11 @@ class TestUGNormalize(TestCase):
}
(users, groups) = self._norm(ug_cfg, distro)
self.assertIn('bob', groups)
- self.assertEquals(['s'], groups['bob'])
- self.assertEquals([], groups['joe'])
+ self.assertEqual(['s'], groups['bob'])
+ self.assertEqual([], groups['joe'])
self.assertIn('joe', groups)
self.assertIn('steve', groups)
- self.assertEquals({}, users)
+ self.assertEqual({}, users)
def test_users_simple_dict(self):
distro = self._make_distro('ubuntu', bcfg)
@@ -128,14 +127,14 @@ class TestUGNormalize(TestCase):
}
}
(users, _groups) = self._norm(ug_cfg, distro)
- self.assertEquals({}, users)
+ self.assertEqual({}, users)
ug_cfg = {
'users': {
'default': 'no',
}
}
(users, _groups) = self._norm(ug_cfg, distro)
- self.assertEquals({}, users)
+ self.assertEqual({}, users)
def test_users_simple_csv(self):
distro = self._make_distro('ubuntu')
@@ -145,8 +144,8 @@ class TestUGNormalize(TestCase):
(users, _groups) = self._norm(ug_cfg, distro)
self.assertIn('joe', users)
self.assertIn('bob', users)
- self.assertEquals({'default': False}, users['joe'])
- self.assertEquals({'default': False}, users['bob'])
+ self.assertEqual({'default': False}, users['joe'])
+ self.assertEqual({'default': False}, users['bob'])
def test_users_simple(self):
distro = self._make_distro('ubuntu')
@@ -159,8 +158,8 @@ class TestUGNormalize(TestCase):
(users, _groups) = self._norm(ug_cfg, distro)
self.assertIn('joe', users)
self.assertIn('bob', users)
- self.assertEquals({'default': False}, users['joe'])
- self.assertEquals({'default': False}, users['bob'])
+ self.assertEqual({'default': False}, users['joe'])
+ self.assertEqual({'default': False}, users['bob'])
def test_users_old_user(self):
distro = self._make_distro('ubuntu', bcfg)
@@ -211,8 +210,8 @@ class TestUGNormalize(TestCase):
self.assertIn('zetta', users)
ug_cfg = {}
(users, groups) = self._norm(ug_cfg, distro)
- self.assertEquals({}, users)
- self.assertEquals({}, groups)
+ self.assertEqual({}, users)
+ self.assertEqual({}, groups)
def test_users_dict_default_additional(self):
distro = self._make_distro('ubuntu', bcfg)
@@ -223,12 +222,10 @@ class TestUGNormalize(TestCase):
}
(users, _groups) = self._norm(ug_cfg, distro)
self.assertIn('bob', users)
- self.assertEquals(",".join(distro.get_default_user()['groups']),
- users['bob']['groups'])
- self.assertEquals(True,
- users['bob']['blah'])
- self.assertEquals(True,
- users['bob']['default'])
+ self.assertEqual(",".join(distro.get_default_user()['groups']),
+ users['bob']['groups'])
+ self.assertEqual(True, users['bob']['blah'])
+ self.assertEqual(True, users['bob']['default'])
def test_users_dict_extract(self):
distro = self._make_distro('ubuntu', bcfg)
@@ -240,7 +237,7 @@ class TestUGNormalize(TestCase):
(users, _groups) = self._norm(ug_cfg, distro)
self.assertIn('bob', users)
(name, config) = distros.extract_default(users)
- self.assertEquals(name, 'bob')
+ self.assertEqual(name, 'bob')
expected_config = {}
def_config = None
try:
@@ -255,7 +252,7 @@ class TestUGNormalize(TestCase):
expected_config.pop('name', None)
expected_config.pop('groups', None)
config.pop('groups', None)
- self.assertEquals(config, expected_config)
+ self.assertEqual(config, expected_config)
def test_users_dict_default(self):
distro = self._make_distro('ubuntu', bcfg)
@@ -266,10 +263,9 @@ class TestUGNormalize(TestCase):
}
(users, _groups) = self._norm(ug_cfg, distro)
self.assertIn('bob', users)
- self.assertEquals(",".join(distro.get_default_user()['groups']),
- users['bob']['groups'])
- self.assertEquals(True,
- users['bob']['default'])
+ self.assertEqual(",".join(distro.get_default_user()['groups']),
+ users['bob']['groups'])
+ self.assertEqual(True, users['bob']['default'])
def test_users_dict_trans(self):
distro = self._make_distro('ubuntu')
@@ -283,8 +279,8 @@ class TestUGNormalize(TestCase):
(users, _groups) = self._norm(ug_cfg, distro)
self.assertIn('joe', users)
self.assertIn('bob', users)
- self.assertEquals({'tr_me': True, 'default': False}, users['joe'])
- self.assertEquals({'default': False}, users['bob'])
+ self.assertEqual({'tr_me': True, 'default': False}, users['joe'])
+ self.assertEqual({'default': False}, users['bob'])
def test_users_dict(self):
distro = self._make_distro('ubuntu')
@@ -297,5 +293,5 @@ class TestUGNormalize(TestCase):
(users, _groups) = self._norm(ug_cfg, distro)
self.assertIn('joe', users)
self.assertIn('bob', users)
- self.assertEquals({'default': False}, users['joe'])
- self.assertEquals({'default': False}, users['bob'])
+ self.assertEqual({'default': False}, users['joe'])
+ self.assertEqual({'default': False}, users['bob'])
diff --git a/tests/unittests/test_ec2_util.py b/tests/unittests/test_ec2_util.py
index 99fc54be..d6cf17fa 100644
--- a/tests/unittests/test_ec2_util.py
+++ b/tests/unittests/test_ec2_util.py
@@ -16,7 +16,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
body='stuff',
status=200)
userdata = eu.get_instance_userdata(self.VERSION)
- self.assertEquals('stuff', userdata.decode('utf-8'))
+ self.assertEqual('stuff', userdata.decode('utf-8'))
@hp.activate
def test_userdata_fetch_fail_not_found(self):
@@ -24,7 +24,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
'http://169.254.169.254/%s/user-data' % (self.VERSION),
status=404)
userdata = eu.get_instance_userdata(self.VERSION, retries=0)
- self.assertEquals('', userdata)
+ self.assertEqual('', userdata)
@hp.activate
def test_userdata_fetch_fail_server_dead(self):
@@ -32,7 +32,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
'http://169.254.169.254/%s/user-data' % (self.VERSION),
status=500)
userdata = eu.get_instance_userdata(self.VERSION, retries=0)
- self.assertEquals('', userdata)
+ self.assertEqual('', userdata)
@hp.activate
def test_userdata_fetch_fail_server_not_found(self):
@@ -40,7 +40,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
'http://169.254.169.254/%s/user-data' % (self.VERSION),
status=404)
userdata = eu.get_instance_userdata(self.VERSION)
- self.assertEquals('', userdata)
+ self.assertEqual('', userdata)
@hp.activate
def test_metadata_fetch_no_keys(self):
@@ -56,9 +56,9 @@ class TestEc2Util(helpers.HttprettyTestCase):
hp.register_uri(hp.GET, uh.combine_url(base_url, 'ami-launch-index'),
status=200, body='1')
md = eu.get_instance_metadata(self.VERSION, retries=0)
- self.assertEquals(md['hostname'], 'ec2.fake.host.name.com')
- self.assertEquals(md['instance-id'], '123')
- self.assertEquals(md['ami-launch-index'], '1')
+ self.assertEqual(md['hostname'], 'ec2.fake.host.name.com')
+ self.assertEqual(md['instance-id'], '123')
+ self.assertEqual(md['ami-launch-index'], '1')
@hp.activate
def test_metadata_fetch_key(self):
@@ -77,9 +77,9 @@ class TestEc2Util(helpers.HttprettyTestCase):
uh.combine_url(base_url, 'public-keys/0/openssh-key'),
status=200, body='ssh-rsa AAAA.....wZEf my-public-key')
md = eu.get_instance_metadata(self.VERSION, retries=0, timeout=0.1)
- self.assertEquals(md['hostname'], 'ec2.fake.host.name.com')
- self.assertEquals(md['instance-id'], '123')
- self.assertEquals(1, len(md['public-keys']))
+ self.assertEqual(md['hostname'], 'ec2.fake.host.name.com')
+ self.assertEqual(md['instance-id'], '123')
+ self.assertEqual(1, len(md['public-keys']))
@hp.activate
def test_metadata_fetch_with_2_keys(self):
@@ -102,9 +102,9 @@ class TestEc2Util(helpers.HttprettyTestCase):
uh.combine_url(base_url, 'public-keys/1/openssh-key'),
status=200, body='ssh-rsa AAAA.....wZEf my-other-key')
md = eu.get_instance_metadata(self.VERSION, retries=0, timeout=0.1)
- self.assertEquals(md['hostname'], 'ec2.fake.host.name.com')
- self.assertEquals(md['instance-id'], '123')
- self.assertEquals(2, len(md['public-keys']))
+ self.assertEqual(md['hostname'], 'ec2.fake.host.name.com')
+ self.assertEqual(md['instance-id'], '123')
+ self.assertEqual(2, len(md['public-keys']))
@hp.activate
def test_metadata_fetch_bdm(self):
@@ -131,9 +131,9 @@ class TestEc2Util(helpers.HttprettyTestCase):
status=200,
body="sdc")
md = eu.get_instance_metadata(self.VERSION, retries=0, timeout=0.1)
- self.assertEquals(md['hostname'], 'ec2.fake.host.name.com')
- self.assertEquals(md['instance-id'], '123')
+ self.assertEqual(md['hostname'], 'ec2.fake.host.name.com')
+ self.assertEqual(md['instance-id'], '123')
bdm = md['block-device-mapping']
- self.assertEquals(2, len(bdm))
- self.assertEquals(bdm['ami'], 'sdb')
- self.assertEquals(bdm['ephemeral0'], 'sdc')
+ self.assertEqual(2, len(bdm))
+ self.assertEqual(bdm['ami'], 'sdb')
+ self.assertEqual(bdm['ephemeral0'], 'sdc')
diff --git a/tests/unittests/test_filters/test_launch_index.py b/tests/unittests/test_filters/test_launch_index.py
index 95d24b9b..395713e6 100644
--- a/tests/unittests/test_filters/test_launch_index.py
+++ b/tests/unittests/test_filters/test_launch_index.py
@@ -25,7 +25,7 @@ class TestLaunchFilter(helpers.ResourceUsingTestCase):
for (index, count) in expected_counts.items():
index = util.safe_int(index)
filtered_message = launch_index.Filter(index).apply(message)
- self.assertEquals(count_messages(filtered_message), count)
+ self.assertEqual(count_messages(filtered_message), count)
# Ensure original message still ok/not modified
self.assertTrue(self.equivalentMessage(message, orig_message))
diff --git a/tests/unittests/test_handler/test_handler_apt_configure.py b/tests/unittests/test_handler/test_handler_apt_configure.py
index 1ed185ca..d1dca2c4 100644
--- a/tests/unittests/test_handler/test_handler_apt_configure.py
+++ b/tests/unittests/test_handler/test_handler_apt_configure.py
@@ -1,6 +1,6 @@
+from cloudinit.config import cc_apt_configure
from cloudinit import util
-from cloudinit.config import cc_apt_configure
from ..helpers import TestCase
import os
diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py
index a6b9c0fd..5e771731 100644
--- a/tests/unittests/test_handler/test_handler_ca_certs.py
+++ b/tests/unittests/test_handler/test_handler_ca_certs.py
@@ -1,8 +1,8 @@
from cloudinit import cloud
+from cloudinit.config import cc_ca_certs
from cloudinit import helpers
from cloudinit import util
-from cloudinit.config import cc_ca_certs
from ..helpers import TestCase
import logging
@@ -176,8 +176,7 @@ class TestAddCaCerts(TestCase):
mock_write.assert_has_calls([
mock.call("/usr/share/ca-certificates/cloud-init-ca-certs.crt",
cert, mode=0o644),
- mock.call("/etc/ca-certificates.conf", expected, omode="wb"),
- ])
+ mock.call("/etc/ca-certificates.conf", expected, omode="wb")])
mock_load.assert_called_once_with("/etc/ca-certificates.conf")
def test_single_cert_no_trailing_cr(self):
@@ -202,8 +201,7 @@ class TestAddCaCerts(TestCase):
mock.call("/etc/ca-certificates.conf",
"%s\n%s\n" % (ca_certs_content,
"cloud-init-ca-certs.crt"),
- omode="wb"),
- ])
+ omode="wb")])
mock_load.assert_called_once_with("/etc/ca-certificates.conf")
@@ -228,8 +226,7 @@ class TestAddCaCerts(TestCase):
mock.call("/etc/ca-certificates.conf",
"%s\n%s\n" % (ca_certs_content,
"cloud-init-ca-certs.crt"),
- omode='wb'),
- ])
+ omode='wb')])
mock_load.assert_called_once_with("/etc/ca-certificates.conf")
@@ -264,8 +261,7 @@ class TestRemoveDefaultCaCerts(TestCase):
mock_delete.assert_has_calls([
mock.call("/usr/share/ca-certificates/"),
- mock.call("/etc/ssl/certs/"),
- ])
+ mock.call("/etc/ssl/certs/")])
mock_write.assert_called_once_with(
"/etc/ca-certificates.conf", "", mode=0o644)
diff --git a/tests/unittests/test_handler/test_handler_chef.py b/tests/unittests/test_handler/test_handler_chef.py
index 7763f23b..7a1bc317 100644
--- a/tests/unittests/test_handler/test_handler_chef.py
+++ b/tests/unittests/test_handler/test_handler_chef.py
@@ -1,21 +1,19 @@
import json
+import logging
import os
-
-from cloudinit.config import cc_chef
+import shutil
+import six
+import tempfile
from cloudinit import cloud
+from cloudinit.config import cc_chef
from cloudinit import distros
from cloudinit import helpers
-from cloudinit import util
from cloudinit.sources import DataSourceNone
+from cloudinit import util
from .. import helpers as t_help
-import six
-import logging
-import shutil
-import tempfile
-
LOG = logging.getLogger(__name__)
CLIENT_TEMPL = os.path.sep.join(["templates", "chef_client.rb.tmpl"])
diff --git a/tests/unittests/test_handler/test_handler_growpart.py b/tests/unittests/test_handler/test_handler_growpart.py
index bef0d80d..e653488a 100644
--- a/tests/unittests/test_handler/test_handler_growpart.py
+++ b/tests/unittests/test_handler/test_handler_growpart.py
@@ -1,7 +1,7 @@
from cloudinit import cloud
+from cloudinit.config import cc_growpart
from cloudinit import util
-from cloudinit.config import cc_growpart
from ..helpers import TestCase
import errno
diff --git a/tests/unittests/test_handler/test_handler_locale.py b/tests/unittests/test_handler/test_handler_locale.py
index de85eff6..c91908f4 100644
--- a/tests/unittests/test_handler/test_handler_locale.py
+++ b/tests/unittests/test_handler/test_handler_locale.py
@@ -64,4 +64,4 @@ class TestLocale(t_help.FilesystemMockingTestCase):
contents = util.load_file('/etc/sysconfig/language', decode=False)
n_cfg = ConfigObj(BytesIO(contents))
- self.assertEquals({'RC_LANG': cfg['locale']}, dict(n_cfg))
+ self.assertEqual({'RC_LANG': cfg['locale']}, dict(n_cfg))
diff --git a/tests/unittests/test_handler/test_handler_lxd.py b/tests/unittests/test_handler/test_handler_lxd.py
index 5f61ba6a..6f90defb 100644
--- a/tests/unittests/test_handler/test_handler_lxd.py
+++ b/tests/unittests/test_handler/test_handler_lxd.py
@@ -1,6 +1,6 @@
from cloudinit.config import cc_lxd
-from cloudinit import (distros, helpers, cloud)
from cloudinit.sources import DataSourceNoCloud
+from cloudinit import (distros, helpers, cloud)
from .. import helpers as t_help
import logging
@@ -42,11 +42,11 @@ class TestLxd(t_help.TestCase):
cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
self.assertTrue(mock_util.which.called)
init_call = mock_util.subp.call_args_list[0][0][0]
- self.assertEquals(init_call,
- ['lxd', 'init', '--auto',
- '--network-address=0.0.0.0',
- '--storage-backend=zfs',
- '--storage-pool=poolname'])
+ self.assertEqual(init_call,
+ ['lxd', 'init', '--auto',
+ '--network-address=0.0.0.0',
+ '--storage-backend=zfs',
+ '--storage-pool=poolname'])
@mock.patch("cloudinit.config.cc_lxd.util")
def test_lxd_install(self, mock_util):
@@ -56,7 +56,7 @@ class TestLxd(t_help.TestCase):
cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
self.assertTrue(cc.distro.install_packages.called)
install_pkg = cc.distro.install_packages.call_args_list[0][0][0]
- self.assertEquals(sorted(install_pkg), ['lxd', 'zfs'])
+ self.assertEqual(sorted(install_pkg), ['lxd', 'zfs'])
@mock.patch("cloudinit.config.cc_lxd.util")
def test_no_init_does_nothing(self, mock_util):
@@ -87,7 +87,7 @@ class TestLxd(t_help.TestCase):
"ipv6_netmask": "64",
"ipv6_nat": "true",
"domain": "lxd"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "true",
"lxd/bridge-name": "testbr0",
@@ -109,7 +109,7 @@ class TestLxd(t_help.TestCase):
"ipv6_address": "fd98:9e0:3744::1",
"ipv6_netmask": "64",
"ipv6_nat": "true"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "true",
"lxd/bridge-ipv6": "true",
@@ -120,7 +120,7 @@ class TestLxd(t_help.TestCase):
def test_lxd_debconf_existing(self):
data = {"mode": "existing",
"name": "testbr0"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "false",
"lxd/use-existing-bridge": "true",
@@ -128,7 +128,7 @@ class TestLxd(t_help.TestCase):
def test_lxd_debconf_none(self):
data = {"mode": "none"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "false",
"lxd/bridge-name": ""})
diff --git a/tests/unittests/test_handler/test_handler_power_state.py b/tests/unittests/test_handler/test_handler_power_state.py
index 04ce5687..feff319d 100644
--- a/tests/unittests/test_handler/test_handler_power_state.py
+++ b/tests/unittests/test_handler/test_handler_power_state.py
@@ -119,7 +119,7 @@ def check_lps_ret(psc_return, mode=None):
try:
float(timeout)
- except:
+ except Exception:
errs.append("timeout failed convert to float")
if len(errs):
diff --git a/tests/unittests/test_handler/test_handler_rsyslog.py b/tests/unittests/test_handler/test_handler_rsyslog.py
index b932165c..38636063 100644
--- a/tests/unittests/test_handler/test_handler_rsyslog.py
+++ b/tests/unittests/test_handler/test_handler_rsyslog.py
@@ -31,7 +31,7 @@ class TestLoadConfig(t_help.TestCase):
'config_dir': "mydir",
'config_filename': 'myfilename',
'service_reload_command': 'auto'}
- )
+ )
self.assertEqual(found, self.basecfg)
diff --git a/tests/unittests/test_handler/test_handler_seed_random.py b/tests/unittests/test_handler/test_handler_seed_random.py
index 98bc9b81..a0390da9 100644
--- a/tests/unittests/test_handler/test_handler_seed_random.py
+++ b/tests/unittests/test_handler/test_handler_seed_random.py
@@ -92,7 +92,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("tiny-tim-was-here", contents)
+ self.assertEqual("tiny-tim-was-here", contents)
def test_append_random_unknown_encoding(self):
data = self._compress(b"tiny-toe")
@@ -117,7 +117,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("tiny-toe", contents)
+ self.assertEqual("tiny-toe", contents)
def test_append_random_gz(self):
data = self._compress(b"big-toe")
@@ -130,7 +130,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("big-toe", contents)
+ self.assertEqual("big-toe", contents)
def test_append_random_base64(self):
data = util.b64e('bubbles')
@@ -143,7 +143,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("bubbles", contents)
+ self.assertEqual("bubbles", contents)
def test_append_random_b64(self):
data = util.b64e('kit-kat')
@@ -156,7 +156,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("kit-kat", contents)
+ self.assertEqual("kit-kat", contents)
def test_append_random_metadata(self):
cfg = {
@@ -168,7 +168,7 @@ class TestRandomSeed(t_help.TestCase):
c = self._get_cloud('ubuntu', {'random_seed': '-so-was-josh'})
cc_seed_random.handle('test', cfg, c, LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals('tiny-tim-was-here-so-was-josh', contents)
+ self.assertEqual('tiny-tim-was-here-so-was-josh', contents)
def test_seed_command_provided_and_available(self):
c = self._get_cloud('ubuntu', {})
diff --git a/tests/unittests/test_handler/test_handler_set_hostname.py b/tests/unittests/test_handler/test_handler_set_hostname.py
index d358b069..7effa124 100644
--- a/tests/unittests/test_handler/test_handler_set_hostname.py
+++ b/tests/unittests/test_handler/test_handler_set_hostname.py
@@ -7,13 +7,11 @@ from cloudinit import util
from .. import helpers as t_help
-import shutil
-import tempfile
+from configobj import ConfigObj
import logging
-
+import shutil
from six import BytesIO
-
-from configobj import ConfigObj
+import tempfile
LOG = logging.getLogger(__name__)
@@ -43,8 +41,8 @@ class TestHostname(t_help.FilesystemMockingTestCase):
if not distro.uses_systemd():
contents = util.load_file("/etc/sysconfig/network", decode=False)
n_cfg = ConfigObj(BytesIO(contents))
- self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
- dict(n_cfg))
+ self.assertEqual({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
+ dict(n_cfg))
def test_write_hostname_debian(self):
cfg = {
@@ -58,7 +56,7 @@ class TestHostname(t_help.FilesystemMockingTestCase):
cc_set_hostname.handle('cc_set_hostname',
cfg, cc, LOG, [])
contents = util.load_file("/etc/hostname")
- self.assertEquals('blah', contents.strip())
+ self.assertEqual('blah', contents.strip())
def test_write_hostname_sles(self):
cfg = {
@@ -71,4 +69,4 @@ class TestHostname(t_help.FilesystemMockingTestCase):
self.patchUtils(self.tmp)
cc_set_hostname.handle('cc_set_hostname', cfg, cc, LOG, [])
contents = util.load_file("/etc/HOSTNAME")
- self.assertEquals('blah', contents.strip())
+ self.assertEqual('blah', contents.strip())
diff --git a/tests/unittests/test_handler/test_handler_snappy.py b/tests/unittests/test_handler/test_handler_snappy.py
index 8aeff53c..57dce1bc 100644
--- a/tests/unittests/test_handler/test_handler_snappy.py
+++ b/tests/unittests/test_handler/test_handler_snappy.py
@@ -1,6 +1,7 @@
from cloudinit.config.cc_snappy import (
makeop, get_package_ops, render_snap_op)
from cloudinit import util
+
from .. import helpers as t_help
import os
diff --git a/tests/unittests/test_handler/test_handler_timezone.py b/tests/unittests/test_handler/test_handler_timezone.py
index e3df8759..b7e6b03d 100644
--- a/tests/unittests/test_handler/test_handler_timezone.py
+++ b/tests/unittests/test_handler/test_handler_timezone.py
@@ -28,12 +28,10 @@ from cloudinit.sources import DataSourceNoCloud
from .. import helpers as t_help
from configobj import ConfigObj
-
-from six import BytesIO
-
+import logging
import shutil
+from six import BytesIO
import tempfile
-import logging
LOG = logging.getLogger(__name__)
@@ -72,7 +70,7 @@ class TestTimezone(t_help.FilesystemMockingTestCase):
contents = util.load_file('/etc/sysconfig/clock', decode=False)
n_cfg = ConfigObj(BytesIO(contents))
- self.assertEquals({'TIMEZONE': cfg['timezone']}, dict(n_cfg))
+ self.assertEqual({'TIMEZONE': cfg['timezone']}, dict(n_cfg))
contents = util.load_file('/etc/localtime')
- self.assertEquals(dummy_contents, contents.strip())
+ self.assertEqual(dummy_contents, contents.strip())
diff --git a/tests/unittests/test_handler/test_handler_write_files.py b/tests/unittests/test_handler/test_handler_write_files.py
index f1c7f7b4..466e45f8 100644
--- a/tests/unittests/test_handler/test_handler_write_files.py
+++ b/tests/unittests/test_handler/test_handler_write_files.py
@@ -1,6 +1,6 @@
-from cloudinit import util
-from cloudinit import log as logging
from cloudinit.config.cc_write_files import write_files
+from cloudinit import log as logging
+from cloudinit import util
from ..helpers import FilesystemMockingTestCase
diff --git a/tests/unittests/test_handler/test_handler_yum_add_repo.py b/tests/unittests/test_handler/test_handler_yum_add_repo.py
index 3a8aa7c1..28b060f8 100644
--- a/tests/unittests/test_handler/test_handler_yum_add_repo.py
+++ b/tests/unittests/test_handler/test_handler_yum_add_repo.py
@@ -1,16 +1,13 @@
-from cloudinit import util
-
from cloudinit.config import cc_yum_add_repo
+from cloudinit import util
from .. import helpers
-import shutil
-import tempfile
+import configobj
import logging
-
+import shutil
from six import BytesIO
-
-import configobj
+import tempfile
LOG = logging.getLogger(__name__)
@@ -68,4 +65,4 @@ class TestConfig(helpers.FilesystemMockingTestCase):
'gpgcheck': '1',
}
}
- self.assertEquals(expected, dict(contents))
+ self.assertEqual(expected, dict(contents))
diff --git a/tests/unittests/test_merging.py b/tests/unittests/test_merging.py
index 976d8283..681f3780 100644
--- a/tests/unittests/test_merging.py
+++ b/tests/unittests/test_merging.py
@@ -133,7 +133,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
for test in test_dicts:
c = _old_mergemanydict(*test)
d = util.mergemanydict(test)
- self.assertEquals(c, d)
+ self.assertEqual(c, d)
def test_merge_cc_samples(self):
tests = self._load_merge_files()
@@ -155,7 +155,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
fail_msg = fail_msg % (expected_fn,
",".join(merging_fns), merged_buf,
expected_merge)
- self.assertEquals(expected_merge, merged_buf, msg=fail_msg)
+ self.assertEqual(expected_merge, merged_buf, msg=fail_msg)
def test_compat_merges_dict(self):
a = {
@@ -167,7 +167,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
}
c = _old_mergedict(a, b)
d = util.mergemanydict([a, b])
- self.assertEquals(c, d)
+ self.assertEqual(c, d)
def test_compat_merges_dict2(self):
a = {
@@ -182,7 +182,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
}
c = _old_mergedict(a, b)
d = util.mergemanydict([a, b])
- self.assertEquals(c, d)
+ self.assertEqual(c, d)
def test_compat_merges_list(self):
a = {'b': [1, 2, 3]}
@@ -190,7 +190,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
c = {'b': [6, 7]}
e = _old_mergemanydict(a, b, c)
f = util.mergemanydict([a, b, c])
- self.assertEquals(e, f)
+ self.assertEqual(e, f)
def test_compat_merges_str(self):
a = {'b': "hi"}
@@ -198,7 +198,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
c = {'b': "hallo"}
e = _old_mergemanydict(a, b, c)
f = util.mergemanydict([a, b, c])
- self.assertEquals(e, f)
+ self.assertEqual(e, f)
def test_compat_merge_sub_dict(self):
a = {
@@ -222,7 +222,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
}
c = _old_mergedict(a, b)
d = util.mergemanydict([a, b])
- self.assertEquals(c, d)
+ self.assertEqual(c, d)
def test_compat_merge_sub_dict2(self):
a = {
@@ -238,7 +238,7 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
}
c = _old_mergedict(a, b)
d = util.mergemanydict([a, b])
- self.assertEquals(c, d)
+ self.assertEqual(c, d)
def test_compat_merge_sub_list(self):
a = {
@@ -254,4 +254,4 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
}
c = _old_mergedict(a, b)
d = util.mergemanydict([a, b])
- self.assertEquals(c, d)
+ self.assertEqual(c, d)
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 09235c4d..624a9aa8 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -1,11 +1,12 @@
-from cloudinit import util
from cloudinit import net
+from cloudinit import util
+
from .helpers import TestCase
import base64
import copy
-import io
import gzip
+import io
import json
import os
diff --git a/tests/unittests/test_reporting.py b/tests/unittests/test_reporting.py
index 32356ef9..5cad8406 100644
--- a/tests/unittests/test_reporting.py
+++ b/tests/unittests/test_reporting.py
@@ -4,8 +4,8 @@
# vi: ts=4 expandtab
from cloudinit import reporting
-from cloudinit.reporting import handlers
from cloudinit.reporting import events
+from cloudinit.reporting import handlers
from .helpers import (mock, TestCase)
diff --git a/tests/unittests/test_rh_subscription.py b/tests/unittests/test_rh_subscription.py
index 8c586ad7..b84c807b 100644
--- a/tests/unittests/test_rh_subscription.py
+++ b/tests/unittests/test_rh_subscription.py
@@ -1,5 +1,6 @@
-from cloudinit import util
from cloudinit.config import cc_rh_subscription
+from cloudinit import util
+
import logging
import mock
import unittest
diff --git a/tests/unittests/test_runs/test_merge_run.py b/tests/unittests/test_runs/test_merge_run.py
index d0ec36a9..ce43798e 100644
--- a/tests/unittests/test_runs/test_merge_run.py
+++ b/tests/unittests/test_runs/test_merge_run.py
@@ -42,13 +42,13 @@ class TestMergeRun(helpers.FilesystemMockingTestCase):
args=[PER_INSTANCE],
freq=PER_INSTANCE)
mirrors = initer.distro.get_option('package_mirrors')
- self.assertEquals(1, len(mirrors))
+ self.assertEqual(1, len(mirrors))
mirror = mirrors[0]
- self.assertEquals(mirror['arches'], ['i386', 'amd64', 'blah'])
+ self.assertEqual(mirror['arches'], ['i386', 'amd64', 'blah'])
mods = stages.Modules(initer)
(which_ran, failures) = mods.run_section('cloud_init_modules')
self.assertTrue(len(failures) == 0)
self.assertTrue(os.path.exists('/etc/blah.ini'))
self.assertIn('write-files', which_ran)
contents = util.load_file('/etc/blah.ini')
- self.assertEquals(contents, 'blah')
+ self.assertEqual(contents, 'blah')
diff --git a/tests/unittests/test_runs/test_simple_run.py b/tests/unittests/test_runs/test_simple_run.py
index e19e65cd..07e7b1a8 100644
--- a/tests/unittests/test_runs/test_simple_run.py
+++ b/tests/unittests/test_runs/test_simple_run.py
@@ -63,7 +63,7 @@ class TestSimpleRun(helpers.FilesystemMockingTestCase):
initer.fetch()
iid = initer.instancify()
- self.assertEquals(iid, 'iid-datasource-none')
+ self.assertEqual(iid, 'iid-datasource-none')
initer.update()
self.assertTrue(os.path.islink("var/lib/cloud/instance"))
@@ -78,4 +78,4 @@ class TestSimpleRun(helpers.FilesystemMockingTestCase):
self.assertTrue(os.path.exists('/etc/blah.ini'))
self.assertIn('write-files', which_ran)
contents = util.load_file('/etc/blah.ini')
- self.assertEquals(contents, 'blah')
+ self.assertEqual(contents, 'blah')
diff --git a/tests/unittests/test_templating.py b/tests/unittests/test_templating.py
index b9863650..94b6e061 100644
--- a/tests/unittests/test_templating.py
+++ b/tests/unittests/test_templating.py
@@ -58,7 +58,7 @@ class TestTemplates(test_helpers.TestCase):
blob = "blahblah $blah"
(template_type, renderer, contents) = templater.detect_template(blob)
self.assertIn("cheetah", template_type)
- self.assertEquals(blob, contents)
+ self.assertEqual(blob, contents)
blob = '##template:something-new'
self.assertRaises(ValueError, templater.detect_template, blob)
@@ -67,18 +67,18 @@ class TestTemplates(test_helpers.TestCase):
blob = '''## template:cheetah
$a,$b'''
c = templater.render_string(blob, {"a": 1, "b": 2})
- self.assertEquals("1,2", c)
+ self.assertEqual("1,2", c)
def test_render_jinja(self):
blob = '''## template:jinja
{{a}},{{b}}'''
c = templater.render_string(blob, {"a": 1, "b": 2})
- self.assertEquals("1,2", c)
+ self.assertEqual("1,2", c)
def test_render_default(self):
blob = '''$a,$b'''
c = templater.render_string(blob, {"a": 1, "b": 2})
- self.assertEquals("1,2", c)
+ self.assertEqual("1,2", c)
def test_render_basic_deeper(self):
hn = 'myfoohost.yahoo.com'