diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-05-22 03:37:47 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-05-22 03:37:47 +0000 |
commit | cc1e163ddcd4de0deb58ff8caeb2afc62200c001 (patch) | |
tree | f3d3f8a0f0bd0cc79f4ced17d8f65c6968b78a25 /tests/utils.py | |
parent | 144c1a7228dd61bfad58069cf885e4ddf0eeb171 (diff) | |
parent | 4ff33b0390fff7e623be7c2242002e32a47eb855 (diff) | |
download | oslo-cc1e163ddcd4de0deb58ff8caeb2afc62200c001.tar.gz oslo-cc1e163ddcd4de0deb58ff8caeb2afc62200c001.tar.xz oslo-cc1e163ddcd4de0deb58ff8caeb2afc62200c001.zip |
Merge "Specify database group instead of DEFAULT"
Diffstat (limited to 'tests/utils.py')
-rw-r--r-- | tests/utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py index c5c7c00..4682428 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -17,6 +17,9 @@ """Common utilities used in testing""" +import os +import tempfile + import fixtures from oslo.config import cfg import testtools @@ -36,6 +39,8 @@ class BaseTestCase(testtools.TestCase): self.useFixture(fixtures.FakeLogger('openstack.common')) self.useFixture(fixtures.Timeout(30, True)) self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True) + self.useFixture(fixtures.NestedTempfile()) + self.tempdirs = [] def tearDown(self): super(BaseTestCase, self).tearDown() @@ -43,6 +48,21 @@ class BaseTestCase(testtools.TestCase): self.stubs.UnsetAll() self.stubs.SmartUnsetAll() + def create_tempfiles(self, files, ext='.conf'): + tempfiles = [] + for (basename, contents) in files: + if not os.path.isabs(basename): + (fd, path) = tempfile.mkstemp(prefix=basename, suffix=ext) + else: + path = basename + ext + fd = os.open(path, os.O_CREAT | os.O_WRONLY) + tempfiles.append(path) + try: + os.write(fd, contents) + finally: + os.close(fd) + return tempfiles + def config(self, **kw): """ Override some configuration values. |