summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/config/cc_landscape.py3
-rw-r--r--cloudinit/distros/__init__.py4
-rw-r--r--cloudinit/mergers/__init__.py5
-rw-r--r--cloudinit/mergers/str.py2
-rw-r--r--cloudinit/sources/DataSourceNone.py1
-rw-r--r--tests/unittests/test__init__.py2
-rw-r--r--tests/unittests/test_merging.py8
-rw-r--r--tests/unittests/test_userdata.py39
8 files changed, 34 insertions, 30 deletions
diff --git a/cloudinit/config/cc_landscape.py b/cloudinit/config/cc_landscape.py
index 47c10a97..8a709677 100644
--- a/cloudinit/config/cc_landscape.py
+++ b/cloudinit/config/cc_landscape.py
@@ -59,7 +59,8 @@ def handle(_name, cfg, cloud, log, _args):
if not isinstance(ls_cloudcfg, (dict)):
raise RuntimeError(("'landscape' key existed in config,"
" but not a dictionary type,"
- " is a %s instead"), type_utils.obj_name(ls_cloudcfg))
+ " is a %s instead"),
+ type_utils.obj_name(ls_cloudcfg))
if not ls_cloudcfg:
return
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 7b6276c5..50d52594 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -741,7 +741,7 @@ def normalize_users_groups(cfg, distro):
}
if not isinstance(old_user, (dict)):
LOG.warn(("Format for 'user' key must be a string or "
- "dictionary and not %s"), util.obj_name(old_user))
+ "dictionary and not %s"), type_utils.obj_name(old_user))
old_user = {}
# If no old user format, then assume the distro
@@ -767,7 +767,7 @@ def normalize_users_groups(cfg, distro):
if not isinstance(base_users, (list, dict, str, basestring)):
LOG.warn(("Format for 'users' key must be a comma separated string"
" or a dictionary or a list and not %s"),
- util.obj_name(base_users))
+ type_utils.obj_name(base_users))
base_users = []
if old_user:
diff --git a/cloudinit/mergers/__init__.py b/cloudinit/mergers/__init__.py
index 3b56686f..ac16f143 100644
--- a/cloudinit/mergers/__init__.py
+++ b/cloudinit/mergers/__init__.py
@@ -32,7 +32,7 @@ class UnknownMerger(object):
# Named differently so auto-method finding
# doesn't pick this up if there is ever a type
# named "unknown"
- def _handle_unknown(self, meth_wanted, value, merge_with):
+ def _handle_unknown(self, _meth_wanted, value, _merge_with):
return value
# This merging will attempt to look for a '_on_X' method
@@ -119,7 +119,8 @@ def string_extract_mergers(merge_how):
continue
match = NAME_MTCH.match(m_name)
if not match:
- msg = "Matcher identifer '%s' is not in the right format" % (m_name)
+ msg = ("Matcher identifer '%s' is not in the right format" %
+ (m_name))
raise ValueError(msg)
(m_name, m_ops) = match.groups()
m_ops = m_ops.strip().split(",")
diff --git a/cloudinit/mergers/str.py b/cloudinit/mergers/str.py
index f1534c5b..291c91c2 100644
--- a/cloudinit/mergers/str.py
+++ b/cloudinit/mergers/str.py
@@ -18,7 +18,7 @@
class Merger(object):
- def __init__(self, merger, opts):
+ def __init__(self, _merger, opts):
self._append = 'append' in opts
# On encountering a unicode object to merge value with
diff --git a/cloudinit/sources/DataSourceNone.py b/cloudinit/sources/DataSourceNone.py
index e2175e1f..12a8a992 100644
--- a/cloudinit/sources/DataSourceNone.py
+++ b/cloudinit/sources/DataSourceNone.py
@@ -18,7 +18,6 @@
from cloudinit import log as logging
from cloudinit import sources
-from cloudinit import util
LOG = logging.getLogger(__name__)
diff --git a/tests/unittests/test__init__.py b/tests/unittests/test__init__.py
index 7924755a..56ccbcfb 100644
--- a/tests/unittests/test__init__.py
+++ b/tests/unittests/test__init__.py
@@ -24,8 +24,6 @@ class FakeModule(handlers.Handler):
def handle_part(self, data, ctype, filename, payload, frequency):
pass
-
-
class TestWalkerHandleHandler(MockerTestCase):
diff --git a/tests/unittests/test_merging.py b/tests/unittests/test_merging.py
index fa7ee8e4..591a99c8 100644
--- a/tests/unittests/test_merging.py
+++ b/tests/unittests/test_merging.py
@@ -1,5 +1,3 @@
-import os
-
from tests.unittests import helpers
from cloudinit import mergers
@@ -107,8 +105,10 @@ class TestSimpleRun(helpers.MockerTestCase):
self.assertEquals(merged['a'], [1, 'b', 2, 'e', 'f', 'g'])
self.assertEquals(merged['b'], 'blahblahmore')
self.assertEquals(merged['c']['f'], 'bigblobofstuff')
- self.assertEquals(merged['run'], ['runme', 'runme2', 'morecmd', 'moremoremore'])
- self.assertEquals(merged['runmereally'], ['e', ['a'], 'd', 'blah', ['b'], 'e'])
+ self.assertEquals(merged['run'], ['runme', 'runme2', 'morecmd',
+ 'moremoremore'])
+ self.assertEquals(merged['runmereally'], ['e', ['a'], 'd', 'blah',
+ ['b'], 'e'])
def test_dict_overwrite_layered(self):
source = {
diff --git a/tests/unittests/test_userdata.py b/tests/unittests/test_userdata.py
index ef0dd7b8..48ad9c5f 100644
--- a/tests/unittests/test_userdata.py
+++ b/tests/unittests/test_userdata.py
@@ -7,8 +7,6 @@ import os
from email.mime.base import MIMEBase
-from mocker import MockerTestCase
-
from cloudinit import handlers
from cloudinit import helpers as c_helpers
from cloudinit import log
@@ -97,14 +95,16 @@ p: 1
new_root = self.makeDir()
self.patchUtils(new_root)
self.patchOS(new_root)
- cloud_cfg.handle_part(None, handlers.CONTENT_START, None, None, None, None)
+ cloud_cfg.handle_part(None, handlers.CONTENT_START, None, None, None,
+ None)
for i, m in enumerate(messages):
headers = dict(m)
fn = "part-%s" % (i + 1)
payload = m.get_payload(decode=True)
cloud_cfg.handle_part(None, headers['Content-Type'],
fn, payload, None, headers)
- cloud_cfg.handle_part(None, handlers.CONTENT_END, None, None, None, None)
+ cloud_cfg.handle_part(None, handlers.CONTENT_END, None, None, None,
+ None)
contents = util.load_file(paths.get_ipath('cloud_config'))
contents = util.load_yaml(contents)
self.assertEquals(contents['run'], ['b', 'c', 'stuff', 'morestuff'])
@@ -118,8 +118,9 @@ p: 1
data = "arbitrary text\n"
ci.datasource = FakeDataSource(data)
- self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
- self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
+ mock_write = self.mocker.replace("cloudinit.util.write_file",
+ passthrough=False)
+ mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
self.mocker.replay()
log_file = self.capture_log(logging.WARNING)
@@ -136,8 +137,9 @@ p: 1
message.set_payload("Just text")
ci.datasource = FakeDataSource(message.as_string())
- self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
- self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
+ mock_write = self.mocker.replace("cloudinit.util.write_file",
+ passthrough=False)
+ mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
self.mocker.replay()
log_file = self.capture_log(logging.WARNING)
@@ -154,9 +156,10 @@ p: 1
ci.datasource = FakeDataSource(script)
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
- self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
- self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
- self.mock_write(outpath, script, 0700)
+ mock_write = self.mocker.replace("cloudinit.util.write_file",
+ passthrough=False)
+ mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
+ mock_write(outpath, script, 0700)
self.mocker.replay()
log_file = self.capture_log(logging.WARNING)
@@ -173,9 +176,10 @@ p: 1
ci.datasource = FakeDataSource(message.as_string())
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
- self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
- self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
- self.mock_write(outpath, script, 0700)
+ mock_write = self.mocker.replace("cloudinit.util.write_file",
+ passthrough=False)
+ mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
+ mock_write(outpath, script, 0700)
self.mocker.replay()
log_file = self.capture_log(logging.WARNING)
@@ -192,9 +196,10 @@ p: 1
ci.datasource = FakeDataSource(message.as_string())
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
- self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
- self.mock_write(outpath, script, 0700)
- self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
+ mock_write = self.mocker.replace("cloudinit.util.write_file",
+ passthrough=False)
+ mock_write(outpath, script, 0700)
+ mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
self.mocker.replay()
log_file = self.capture_log(logging.WARNING)