summaryrefslogtreecommitdiff
path: root/tests/unittests/test__init__.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-03-02 15:56:15 -0500
committerScott Moser <smoser@ubuntu.com>2015-03-02 15:56:15 -0500
commita934ae9543ccc9c13fbdedddcc04fa82853a7ec2 (patch)
treeb206a17a678b109ca259f3a18b9c41563dfbf8fd /tests/unittests/test__init__.py
parentb2af44fb22719dc353bd867c2648e0dd5b2eec19 (diff)
downloadvyos-cloud-init-a934ae9543ccc9c13fbdedddcc04fa82853a7ec2.tar.gz
vyos-cloud-init-a934ae9543ccc9c13fbdedddcc04fa82853a7ec2.zip
get_cmdline_url: fix in python3 when calling
get_cmdline_url was passing a string to response.contents.startswith() where response.contents is now bytes. this changes it to convert input to text, and also to default to text.
Diffstat (limited to 'tests/unittests/test__init__.py')
-rw-r--r--tests/unittests/test__init__.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/unittests/test__init__.py b/tests/unittests/test__init__.py
index 1a307e56..c32783a6 100644
--- a/tests/unittests/test__init__.py
+++ b/tests/unittests/test__init__.py
@@ -181,7 +181,7 @@ class TestCmdlineUrl(unittest.TestCase):
def test_invalid_content(self):
url = "http://example.com/foo"
key = "mykey"
- payload = "0"
+ payload = b"0"
cmdline = "ro %s=%s bar=1" % (key, url)
with mock.patch('cloudinit.url_helper.readurl',
@@ -194,13 +194,13 @@ class TestCmdlineUrl(unittest.TestCase):
def test_valid_content(self):
url = "http://example.com/foo"
key = "mykey"
- payload = "xcloud-config\nmydata: foo\nbar: wark\n"
+ payload = b"xcloud-config\nmydata: foo\nbar: wark\n"
cmdline = "ro %s=%s bar=1" % (key, url)
with mock.patch('cloudinit.url_helper.readurl',
return_value=url_helper.StringResponse(payload)):
self.assertEqual(
- util.get_cmdline_url(names=[key], starts="xcloud-config",
+ util.get_cmdline_url(names=[key], starts=b"xcloud-config",
cmdline=cmdline),
(key, url, payload))
@@ -210,7 +210,7 @@ class TestCmdlineUrl(unittest.TestCase):
cmdline = "ro %s=%s bar=1" % (key, url)
with mock.patch('cloudinit.url_helper.readurl',
- return_value=url_helper.StringResponse('')):
+ return_value=url_helper.StringResponse(b'')):
self.assertEqual(
util.get_cmdline_url(names=["does-not-appear"],
starts="#cloud-config", cmdline=cmdline),