summaryrefslogtreecommitdiff
path: root/tests/unittests/test_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/test_util.py')
-rw-r--r--tests/unittests/test_util.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 5a14479a..9ff17f52 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -2,26 +2,21 @@
from __future__ import print_function
+import io
+import json
import logging
import os
import re
import shutil
import stat
-import tempfile
-
-import json
-import six
import sys
+import tempfile
import yaml
+from unittest import mock
from cloudinit import importer, util
from cloudinit.tests import helpers
-try:
- from unittest import mock
-except ImportError:
- import mock
-
BASH = util.which('bash')
BOGUS_COMMAND = 'this-is-not-expected-to-be-a-program-name'
@@ -320,7 +315,7 @@ class TestLoadYaml(helpers.CiTestCase):
def test_python_unicode(self):
# complex type of python/unicode is explicitly allowed
- myobj = {'1': six.text_type("FOOBAR")}
+ myobj = {'1': "FOOBAR"}
safe_yaml = yaml.dump(myobj)
self.assertEqual(util.load_yaml(blob=safe_yaml,
default=self.mydefault),
@@ -663,8 +658,8 @@ class TestMultiLog(helpers.FilesystemMockingTestCase):
self.patchOS(self.root)
self.patchUtils(self.root)
self.patchOpen(self.root)
- self.stdout = six.StringIO()
- self.stderr = six.StringIO()
+ self.stdout = io.StringIO()
+ self.stderr = io.StringIO()
self.patchStdoutAndStderr(self.stdout, self.stderr)
def test_stderr_used_by_default(self):
@@ -879,8 +874,8 @@ class TestSubp(helpers.CiTestCase):
"""Raised exc should have stderr, stdout as string if no decode."""
with self.assertRaises(util.ProcessExecutionError) as cm:
util.subp([BOGUS_COMMAND], decode=True)
- self.assertTrue(isinstance(cm.exception.stdout, six.string_types))
- self.assertTrue(isinstance(cm.exception.stderr, six.string_types))
+ self.assertTrue(isinstance(cm.exception.stdout, str))
+ self.assertTrue(isinstance(cm.exception.stderr, str))
def test_bunch_of_slashes_in_path(self):
self.assertEqual("/target/my/path/",
@@ -1171,4 +1166,10 @@ class TestGetProcEnv(helpers.TestCase):
self.assertEqual({}, util.get_proc_env(1))
self.assertEqual(1, m_load_file.call_count)
+ def test_get_proc_ppid(self):
+ """get_proc_ppid returns correct parent pid value."""
+ my_pid = os.getpid()
+ my_ppid = os.getppid()
+ self.assertEqual(my_ppid, util.get_proc_ppid(my_pid))
+
# vi: ts=4 expandtab