diff options
| author | Scott Moser <smoser@ubuntu.com> | 2016-03-14 14:16:49 -0400 |
|---|---|---|
| committer | Scott Moser <smoser@ubuntu.com> | 2016-03-14 14:16:49 -0400 |
| commit | 92db1b884bf34339a4536a20123c45b01c9c49ce (patch) | |
| tree | 22be0de3d0496212d26015c3b30423da9338aa5c /tests/unittests/test_pathprefix2dict.py | |
| parent | 91ccf1b55b5b79694449446b029dd7c4570517a5 (diff) | |
| parent | 72f826bff694b612d54b177635ca7e0dc83aed2f (diff) | |
| download | vyos-cloud-init-92db1b884bf34339a4536a20123c45b01c9c49ce.tar.gz vyos-cloud-init-92db1b884bf34339a4536a20123c45b01c9c49ce.zip | |
merge with trunk
Diffstat (limited to 'tests/unittests/test_pathprefix2dict.py')
| -rw-r--r-- | tests/unittests/test_pathprefix2dict.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/unittests/test_pathprefix2dict.py b/tests/unittests/test_pathprefix2dict.py index 590c4b82..38fd75b6 100644 --- a/tests/unittests/test_pathprefix2dict.py +++ b/tests/unittests/test_pathprefix2dict.py @@ -1,37 +1,41 @@ from cloudinit import util -from mocker import MockerTestCase -from .helpers import populate_dir +from .helpers import TestCase, populate_dir +import shutil +import tempfile -class TestPathPrefix2Dict(MockerTestCase): + +class TestPathPrefix2Dict(TestCase): def setUp(self): - self.tmp = self.makeDir() + super(TestPathPrefix2Dict, self).setUp() + self.tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.tmp) def test_required_only(self): - dirdata = {'f1': 'f1content', 'f2': 'f2content'} + dirdata = {'f1': b'f1content', 'f2': b'f2content'} populate_dir(self.tmp, dirdata) ret = util.pathprefix2dict(self.tmp, required=['f1', 'f2']) self.assertEqual(dirdata, ret) def test_required_missing(self): - dirdata = {'f1': 'f1content'} + dirdata = {'f1': b'f1content'} populate_dir(self.tmp, dirdata) kwargs = {'required': ['f1', 'f2']} self.assertRaises(ValueError, util.pathprefix2dict, self.tmp, **kwargs) def test_no_required_and_optional(self): - dirdata = {'f1': 'f1c', 'f2': 'f2c'} + dirdata = {'f1': b'f1c', 'f2': b'f2c'} populate_dir(self.tmp, dirdata) ret = util.pathprefix2dict(self.tmp, required=None, - optional=['f1', 'f2']) + optional=['f1', 'f2']) self.assertEqual(dirdata, ret) def test_required_and_optional(self): - dirdata = {'f1': 'f1c', 'f2': 'f2c'} + dirdata = {'f1': b'f1c', 'f2': b'f2c'} populate_dir(self.tmp, dirdata) ret = util.pathprefix2dict(self.tmp, required=['f1'], optional=['f2']) |
