summaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authorDavanum Srinivas <dims@linux.vnet.ibm.com>2013-04-23 09:54:22 -0400
committerDavanum Srinivas <dims@linux.vnet.ibm.com>2013-05-20 21:05:22 -0400
commit4ff33b0390fff7e623be7c2242002e32a47eb855 (patch)
tree5b126191bc62466fa1f55768b2dc1f345172a39a /tests/utils.py
parent97bb81ddbcc47343c78e0a6efe724878fcb35ecb (diff)
downloadoslo-4ff33b0390fff7e623be7c2242002e32a47eb855.tar.gz
oslo-4ff33b0390fff7e623be7c2242002e32a47eb855.tar.xz
oslo-4ff33b0390fff7e623be7c2242002e32a47eb855.zip
Specify database group instead of DEFAULT
At the request of Quantum folks, Let us switch from DEFAULT to database for the database related options. This will help with migration etc. DocImpact Fixes LP# 1171837 Change-Id: If602a6a7cc0f2a202632dd14574fea60dce4b589
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py20
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.