summaryrefslogtreecommitdiff
path: root/tests/unittests/helpers.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-08-19 13:58:52 -0400
committerScott Moser <smoser@brickies.net>2016-08-22 12:58:33 -0400
commit685ffd49561bb92971f6b76e4690b86d7d6ecc0f (patch)
tree7f71a18d816476359435baeaa9334a95ffba1df1 /tests/unittests/helpers.py
parent1f8b37e0d80534d2055ee2e888f5a7e36c4b98b4 (diff)
downloadvyos-cloud-init-685ffd49561bb92971f6b76e4690b86d7d6ecc0f.tar.gz
vyos-cloud-init-685ffd49561bb92971f6b76e4690b86d7d6ecc0f.zip
Minor cleanups to atomic_helper and add unit tests.
Change atomic_helper.write_file to have same same signature as write_file. Add some simple unit tests for atomic_helper.
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r--tests/unittests/helpers.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index de2cf638..1cdc05a1 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -252,6 +252,20 @@ class HttprettyTestCase(TestCase):
super(HttprettyTestCase, self).tearDown()
+class TempDirTestCase(TestCase):
+ # provide a tempdir per class, not per test.
+ def setUp(self):
+ super(TempDirTestCase, self).setUp()
+ self.tmp = tempfile.mkdtemp()
+ self.addCleanup(shutil.rmtree, self.tmp)
+
+ def tmp_path(self, path):
+ if path.startswith(os.path.sep):
+ path = "." + path
+
+ return os.path.normpath(os.path.join(self.tmp, path))
+
+
def populate_dir(path, files):
if not os.path.exists(path):
os.makedirs(path)