From 685ffd49561bb92971f6b76e4690b86d7d6ecc0f Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 19 Aug 2016 13:58:52 -0400 Subject: 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. --- tests/unittests/helpers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/unittests/helpers.py') 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) -- cgit v1.2.3