summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-01-23 09:59:46 -0500
committerMonty Taylor <mordred@inaugust.com>2013-01-24 16:30:26 +1100
commit8c80224ecb5194a5e2ed5f74f1c7f457202d21a3 (patch)
treea557a9524e402e8cd98da702ea805c1cf8d430bb /tests
parent3d2800087ce38ff954c50e5a86916784682ed1bd (diff)
downloadoslo-8c80224ecb5194a5e2ed5f74f1c7f457202d21a3.tar.gz
oslo-8c80224ecb5194a5e2ed5f74f1c7f457202d21a3.tar.xz
oslo-8c80224ecb5194a5e2ed5f74f1c7f457202d21a3.zip
Replace direct use of testtools BaseTestCase.
Using the BaseTestCase across the tests in the tree lets us put in log fixtures and consistently handle mox and stubout. Part of blueprint grizzly-testtools. Change-Id: Iba7eb2c63b0c514009b2c28e5930b27726a147b0
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/middleware/test_context.py7
-rw-r--r--tests/unit/rpc/test_dispatcher.py5
-rw-r--r--tests/unit/rpc/test_kombu.py1
-rw-r--r--tests/unit/rpc/test_matchmaker.py12
-rw-r--r--tests/unit/scheduler/test_weights.py5
-rw-r--r--tests/unit/test_authutils.py5
-rw-r--r--tests/unit/test_cliutils.py5
-rw-r--r--tests/unit/test_context.py5
-rw-r--r--tests/unit/test_exception.py13
-rw-r--r--tests/unit/test_excutils.py5
-rw-r--r--tests/unit/test_fileutils.py5
-rw-r--r--tests/unit/test_gettext.py4
-rw-r--r--tests/unit/test_importutils.py4
-rw-r--r--tests/unit/test_iniparser.py9
-rw-r--r--tests/unit/test_jsonutils.py6
-rw-r--r--tests/unit/test_local.py4
-rw-r--r--tests/unit/test_lockutils.py7
-rw-r--r--tests/unit/test_loopingcall.py4
-rw-r--r--tests/unit/test_network_utils.py26
-rw-r--r--tests/unit/test_pastedeploy.py4
-rw-r--r--tests/unit/test_plugin.py9
-rw-r--r--tests/unit/test_policy.py42
-rw-r--r--tests/unit/test_processutils.py7
-rw-r--r--tests/unit/test_setup.py8
-rw-r--r--tests/unit/test_strutils.py5
-rw-r--r--tests/unit/test_timeutils.py6
-rw-r--r--tests/unit/test_uuidutils.py4
-rw-r--r--tests/unit/test_version.py1
-rw-r--r--tests/unit/test_wsgi.py32
-rw-r--r--tests/utils.py3
30 files changed, 121 insertions, 132 deletions
diff --git a/tests/unit/middleware/test_context.py b/tests/unit/middleware/test_context.py
index 3d48c23..a3c718e 100644
--- a/tests/unit/middleware/test_context.py
+++ b/tests/unit/middleware/test_context.py
@@ -15,16 +15,15 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
import mock
import openstack.common.context
from openstack.common.middleware import context
+from tests import utils
-class ContextMiddlewareTest(testtools.TestCase):
+class ContextMiddlewareTest(utils.BaseTestCase):
def test_process_request(self):
req = mock.Mock()
@@ -60,7 +59,7 @@ class ContextMiddlewareTest(testtools.TestCase):
import_class.assert_called_with(mock.sentinel.arg)
-class FilterFactoryTest(testtools.TestCase):
+class FilterFactoryTest(utils.BaseTestCase):
def test_filter_factory(self):
global_conf = dict(sentinel=mock.sentinel.global_conf)
diff --git a/tests/unit/rpc/test_dispatcher.py b/tests/unit/rpc/test_dispatcher.py
index f41abdf..fe49776 100644
--- a/tests/unit/rpc/test_dispatcher.py
+++ b/tests/unit/rpc/test_dispatcher.py
@@ -18,14 +18,13 @@
Unit Tests for rpc.dispatcher
"""
-import testtools
-
from openstack.common import context
from openstack.common.rpc import common as rpc_common
from openstack.common.rpc import dispatcher
+from tests import utils
-class RpcDispatcherTestCase(testtools.TestCase):
+class RpcDispatcherTestCase(utils.BaseTestCase):
class API1(object):
RPC_API_VERSION = '1.0'
diff --git a/tests/unit/rpc/test_kombu.py b/tests/unit/rpc/test_kombu.py
index d777a8a..b28c568 100644
--- a/tests/unit/rpc/test_kombu.py
+++ b/tests/unit/rpc/test_kombu.py
@@ -24,7 +24,6 @@ eventlet.monkey_patch()
import contextlib
import logging
-import testtools
from openstack.common import cfg
from openstack.common import exception
diff --git a/tests/unit/rpc/test_matchmaker.py b/tests/unit/rpc/test_matchmaker.py
index ddfb776..484e182 100644
--- a/tests/unit/rpc/test_matchmaker.py
+++ b/tests/unit/rpc/test_matchmaker.py
@@ -15,15 +15,15 @@
# under the License.
import logging
-import testtools
from openstack.common.rpc import matchmaker
+from tests import utils
LOG = logging.getLogger(__name__)
-class _MatchMakerTestCase(testtools.TestCase):
+class _MatchMakerTestCase(object):
def test_valid_host_matches(self):
queues = self.driver.queues(self.topic)
matched_hosts = map(lambda x: x[1], queues)
@@ -41,20 +41,20 @@ class _MatchMakerTestCase(testtools.TestCase):
self.assertTrue(host in matched_hosts)
-class MatchMakerFileTestCase(_MatchMakerTestCase):
+class MatchMakerFileTestCase(utils.BaseTestCase, _MatchMakerTestCase):
def setUp(self):
+ super(MatchMakerFileTestCase, self).setUp()
self.topic = "test"
self.hosts = ['hello', 'world', 'foo', 'bar', 'baz']
ring = {
self.topic: self.hosts
}
self.driver = matchmaker.MatchMakerRing(ring)
- super(MatchMakerFileTestCase, self).setUp()
-class MatchMakerLocalhostTestCase(_MatchMakerTestCase):
+class MatchMakerLocalhostTestCase(utils.BaseTestCase, _MatchMakerTestCase):
def setUp(self):
+ super(MatchMakerLocalhostTestCase, self).setUp()
self.driver = matchmaker.MatchMakerLocalhost()
self.topic = "test"
self.hosts = ['localhost']
- super(MatchMakerLocalhostTestCase, self).setUp()
diff --git a/tests/unit/scheduler/test_weights.py b/tests/unit/scheduler/test_weights.py
index ca61c00..76c62ba 100644
--- a/tests/unit/scheduler/test_weights.py
+++ b/tests/unit/scheduler/test_weights.py
@@ -16,13 +16,12 @@
Tests For Scheduler weights.
"""
-import testtools
-
from openstack.common.scheduler import weight
from tests.unit import fakes
+from tests import utils
-class TestWeightHandler(testtools.TestCase):
+class TestWeightHandler(utils.BaseTestCase):
def test_get_all_classes(self):
namespace = "openstack.common.tests.fakes.weights"
handler = weight.BaseWeightHandler(weight.BaseWeigher, namespace)
diff --git a/tests/unit/test_authutils.py b/tests/unit/test_authutils.py
index 64e241a..8c0a54c 100644
--- a/tests/unit/test_authutils.py
+++ b/tests/unit/test_authutils.py
@@ -15,12 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from openstack.common import authutils
+from tests import utils
-class AuthUtilsTest(testtools.TestCase):
+class AuthUtilsTest(utils.BaseTestCase):
def test_auth_str_equal(self):
self.assertTrue(authutils.auth_str_equal('abc123', 'abc123'))
diff --git a/tests/unit/test_cliutils.py b/tests/unit/test_cliutils.py
index c9ab0f5..08bd97b 100644
--- a/tests/unit/test_cliutils.py
+++ b/tests/unit/test_cliutils.py
@@ -14,12 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from openstack.common.cliutils import *
+from tests import utils
-class ValidateArgsTest(testtools.TestCase):
+class ValidateArgsTest(utils.BaseTestCase):
def test_lambda_no_args(self):
validate_args(lambda: None)
diff --git a/tests/unit/test_context.py b/tests/unit/test_context.py
index 3437475..87c3d60 100644
--- a/tests/unit/test_context.py
+++ b/tests/unit/test_context.py
@@ -15,12 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from openstack.common import context
+from tests import utils
-class ContextTest(testtools.TestCase):
+class ContextTest(utils.BaseTestCase):
def test_context(self):
ctx = context.RequestContext()
diff --git a/tests/unit/test_exception.py b/tests/unit/test_exception.py
index ecfadb6..c03a41d 100644
--- a/tests/unit/test_exception.py
+++ b/tests/unit/test_exception.py
@@ -15,9 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from openstack.common import exception
+from tests import utils
def good_function():
@@ -32,7 +31,7 @@ def bad_function_exception():
raise Exception()
-class WrapExceptionTest(testtools.TestCase):
+class WrapExceptionTest(utils.BaseTestCase):
def test_wrap_exception_good_return(self):
wrapped = exception.wrap_exception
@@ -47,7 +46,7 @@ class WrapExceptionTest(testtools.TestCase):
self.assertRaises(Exception, wrapped(bad_function_exception))
-class ApiErrorTest(testtools.TestCase):
+class ApiErrorTest(utils.BaseTestCase):
def test_without_code(self):
err = exception.ApiError('fake error')
@@ -62,7 +61,7 @@ class ApiErrorTest(testtools.TestCase):
self.assertEqual(err.message, 'fake error')
-class BadStoreUriTest(testtools.TestCase):
+class BadStoreUriTest(utils.BaseTestCase):
def test(self):
uri = 'http:///etc/passwd'
@@ -72,7 +71,7 @@ class BadStoreUriTest(testtools.TestCase):
self.assertTrue(reason in str(err.message))
-class UnknownSchemeTest(testtools.TestCase):
+class UnknownSchemeTest(utils.BaseTestCase):
def test(self):
scheme = 'http'
@@ -80,7 +79,7 @@ class UnknownSchemeTest(testtools.TestCase):
self.assertTrue(scheme in str(err.message))
-class OpenstackExceptionTest(testtools.TestCase):
+class OpenstackExceptionTest(utils.BaseTestCase):
class TestException(exception.OpenstackException):
message = '%(test)s'
diff --git a/tests/unit/test_excutils.py b/tests/unit/test_excutils.py
index 35ce5be..d3eeb8c 100644
--- a/tests/unit/test_excutils.py
+++ b/tests/unit/test_excutils.py
@@ -14,12 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from openstack.common import excutils
+from tests import utils
-class SaveAndReraiseTest(testtools.TestCase):
+class SaveAndReraiseTest(utils.BaseTestCase):
def test_save_and_reraise_exception(self):
e = None
diff --git a/tests/unit/test_fileutils.py b/tests/unit/test_fileutils.py
index 1f8ccd6..5deafac 100644
--- a/tests/unit/test_fileutils.py
+++ b/tests/unit/test_fileutils.py
@@ -15,16 +15,15 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
import os
import shutil
import tempfile
from openstack.common import fileutils
+from tests import utils
-class EnsureTree(testtools.TestCase):
+class EnsureTree(utils.BaseTestCase):
def test_ensure_tree(self):
tmpdir = tempfile.mkdtemp()
try:
diff --git a/tests/unit/test_gettext.py b/tests/unit/test_gettext.py
index ddaca16..cedc25c 100644
--- a/tests/unit/test_gettext.py
+++ b/tests/unit/test_gettext.py
@@ -16,15 +16,15 @@
# under the License.
import logging
-import testtools
from openstack.common.gettextutils import _
+from tests import utils
LOG = logging.getLogger(__name__)
-class GettextTest(testtools.TestCase):
+class GettextTest(utils.BaseTestCase):
def test_gettext_does_not_blow_up(self):
LOG.info(_('test'))
diff --git a/tests/unit/test_importutils.py b/tests/unit/test_importutils.py
index 4fb894c..4888287 100644
--- a/tests/unit/test_importutils.py
+++ b/tests/unit/test_importutils.py
@@ -17,12 +17,12 @@
import datetime
import sys
-import testtools
from openstack.common import importutils
+from tests import utils
-class ImportUtilsTest(testtools.TestCase):
+class ImportUtilsTest(utils.BaseTestCase):
# NOTE(jkoelker) There has GOT to be a way to test this. But mocking
# __import__ is the devil. Right now we just make
diff --git a/tests/unit/test_iniparser.py b/tests/unit/test_iniparser.py
index 6742b19..1dcb9a0 100644
--- a/tests/unit/test_iniparser.py
+++ b/tests/unit/test_iniparser.py
@@ -14,9 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from openstack.common import iniparser
+from tests import utils
class TestParser(iniparser.BaseParser):
@@ -38,7 +37,7 @@ class TestParser(iniparser.BaseParser):
self.comment_called = True
-class BaseParserTestCase(testtools.TestCase):
+class BaseParserTestCase(utils.BaseTestCase):
def setUp(self):
super(BaseParserTestCase, self).setUp()
self.parser = iniparser.BaseParser()
@@ -62,7 +61,7 @@ class BaseParserTestCase(testtools.TestCase):
self._assertParseError("[]")
-class ParserTestCase(testtools.TestCase):
+class ParserTestCase(utils.BaseTestCase):
def setUp(self):
super(ParserTestCase, self).setUp()
self.parser = TestParser()
@@ -122,7 +121,7 @@ class ParserTestCase(testtools.TestCase):
self.assertEquals(self.parser.values, {'': {'foo': [' bar ']}})
-class ExceptionTestCase(testtools.TestCase):
+class ExceptionTestCase(utils.BaseTestCase):
def test_parseerror(self):
exc = iniparser.ParseError('test', 42, 'example')
self.assertEquals(str(exc), "at line 42, test: 'example'")
diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py
index eebbfb8..f618a05 100644
--- a/tests/unit/test_jsonutils.py
+++ b/tests/unit/test_jsonutils.py
@@ -17,13 +17,13 @@
import datetime
import StringIO
-import testtools
import xmlrpclib
from openstack.common import jsonutils
+from tests import utils
-class JSONUtilsTestCase(testtools.TestCase):
+class JSONUtilsTestCase(utils.BaseTestCase):
def test_dumps(self):
self.assertEqual(jsonutils.dumps({'a': 'b'}), '{"a": "b"}')
@@ -36,7 +36,7 @@ class JSONUtilsTestCase(testtools.TestCase):
self.assertEqual(jsonutils.load(x), {'a': 'b'})
-class ToPrimitiveTestCase(testtools.TestCase):
+class ToPrimitiveTestCase(utils.BaseTestCase):
def test_list(self):
self.assertEquals(jsonutils.to_primitive([1, 2, 3]), [1, 2, 3])
diff --git a/tests/unit/test_local.py b/tests/unit/test_local.py
index 7031e6f..4806038 100644
--- a/tests/unit/test_local.py
+++ b/tests/unit/test_local.py
@@ -16,9 +16,9 @@
# under the License.
import eventlet
-import testtools
from openstack.common import local
+from tests import utils
class Dict(dict):
@@ -26,7 +26,7 @@ class Dict(dict):
pass
-class LocalStoreTestCase(testtools.TestCase):
+class LocalStoreTestCase(utils.BaseTestCase):
v1 = Dict(a='1')
v2 = Dict(a='2')
v3 = Dict(a='3')
diff --git a/tests/unit/test_lockutils.py b/tests/unit/test_lockutils.py
index dc8e413..5d4b7ad 100644
--- a/tests/unit/test_lockutils.py
+++ b/tests/unit/test_lockutils.py
@@ -21,17 +21,16 @@ import select
import shutil
import tempfile
import time
-import testtools
import eventlet
from eventlet import greenpool
from eventlet import greenthread
from openstack.common import lockutils
-from tests import utils as test_utils
+from tests import utils
-class TestFileLocks(test_utils.BaseTestCase):
+class TestFileLocks(utils.BaseTestCase):
def test_concurrent_green_lock_succeeds(self):
"""Verify spawn_n greenthreads with two locks run concurrently."""
tmpdir = tempfile.mkdtemp()
@@ -66,7 +65,7 @@ class TestFileLocks(test_utils.BaseTestCase):
shutil.rmtree(tmpdir)
-class LockTestCase(test_utils.BaseTestCase):
+class LockTestCase(utils.BaseTestCase):
def test_synchronized_wrapped_function_metadata(self):
@lockutils.synchronized('whatever', 'test-')
def foo():
diff --git a/tests/unit/test_loopingcall.py b/tests/unit/test_loopingcall.py
index 0407668..ef09d2b 100644
--- a/tests/unit/test_loopingcall.py
+++ b/tests/unit/test_loopingcall.py
@@ -15,16 +15,16 @@
# under the License.
import datetime
-import testtools
from eventlet import greenthread
import mox
from openstack.common import loopingcall
from openstack.common import timeutils
+from tests import utils
-class LoopingCallTestCase(testtools.TestCase):
+class LoopingCallTestCase(utils.BaseTestCase):
def setUp(self):
super(LoopingCallTestCase, self).setUp()
diff --git a/tests/unit/test_network_utils.py b/tests/unit/test_network_utils.py
index b5b649a..c20711a 100644
--- a/tests/unit/test_network_utils.py
+++ b/tests/unit/test_network_utils.py
@@ -15,28 +15,30 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
import mock
-from openstack.common import network_utils as utils
+from openstack.common import network_utils
+from tests import utils
-class NetworkUtilsTest(testtools.TestCase):
+class NetworkUtilsTest(utils.BaseTestCase):
def test_parse_host_port(self):
self.assertEqual(('server01', 80),
- utils.parse_host_port('server01:80'))
+ network_utils.parse_host_port('server01:80'))
self.assertEqual(('server01', None),
- utils.parse_host_port('server01'))
+ network_utils.parse_host_port('server01'))
self.assertEqual(('server01', 1234),
- utils.parse_host_port('server01', default_port=1234))
+ network_utils.parse_host_port('server01',
+ default_port=1234))
self.assertEqual(('::1', 80),
- utils.parse_host_port('[::1]:80'))
+ network_utils.parse_host_port('[::1]:80'))
self.assertEqual(('::1', None),
- utils.parse_host_port('[::1]'))
+ network_utils.parse_host_port('[::1]'))
self.assertEqual(('::1', 1234),
- utils.parse_host_port('[::1]', default_port=1234))
+ network_utils.parse_host_port('[::1]',
+ default_port=1234))
self.assertEqual(('2001:db8:85a3::8a2e:370:7334', 1234),
- utils.parse_host_port('2001:db8:85a3::8a2e:370:7334',
- default_port=1234))
+ network_utils.parse_host_port(
+ '2001:db8:85a3::8a2e:370:7334',
+ default_port=1234))
diff --git a/tests/unit/test_pastedeploy.py b/tests/unit/test_pastedeploy.py
index 817eb47..3dd02d7 100644
--- a/tests/unit/test_pastedeploy.py
+++ b/tests/unit/test_pastedeploy.py
@@ -18,9 +18,9 @@ import os
import tempfile
import fixtures
-import testtools
from openstack.common import pastedeploy
+from tests import utils
class App(object):
@@ -43,7 +43,7 @@ class Filter(object):
self.data = data
-class PasteTestCase(testtools.TestCase):
+class PasteTestCase(utils.BaseTestCase):
def setUp(self):
super(PasteTestCase, self).setUp()
diff --git a/tests/unit/test_plugin.py b/tests/unit/test_plugin.py
index efebead..510e915 100644
--- a/tests/unit/test_plugin.py
+++ b/tests/unit/test_plugin.py
@@ -14,13 +14,12 @@
# under the License.
import pkg_resources
-import testtools
from openstack.common import cfg
from openstack.common.notifier import api as notifier_api
from openstack.common.plugin import plugin
from openstack.common.plugin import pluginmanager
-from tests import utils as test_utils
+from tests import utils
class SimpleNotifier(object):
@@ -32,13 +31,13 @@ class SimpleNotifier(object):
self.message_list.append(message)
-class ManagerTestCase(test_utils.BaseTestCase):
+class ManagerTestCase(utils.BaseTestCase):
def test_constructs(self):
manager1 = pluginmanager.PluginManager("testproject", "testservice")
self.assertNotEqual(manager1, False)
-class NotifyTestCase(test_utils.BaseTestCase):
+class NotifyTestCase(utils.BaseTestCase):
"""Test case for the plugin notification interface"""
def test_add_notifier(self):
@@ -100,7 +99,7 @@ class MockExtManager():
self.descriptors.append(descriptor)
-class APITestCase(test_utils.BaseTestCase):
+class APITestCase(utils.BaseTestCase):
"""Test case for the plugin api extension interface"""
def test_add_extension(self):
def mock_load(_s):
diff --git a/tests/unit/test_policy.py b/tests/unit/test_policy.py
index 2ffa7f8..8d6a5b3 100644
--- a/tests/unit/test_policy.py
+++ b/tests/unit/test_policy.py
@@ -19,7 +19,6 @@
import os.path
import StringIO
-import testtools
import urllib
import mock
@@ -27,6 +26,7 @@ import urllib2
from openstack.common import jsonutils
from openstack.common import policy
+from tests import utils
class TestException(Exception):
@@ -35,7 +35,7 @@ class TestException(Exception):
self.kwargs = kwargs
-class RulesTestCase(testtools.TestCase):
+class RulesTestCase(utils.BaseTestCase):
def test_init_basic(self):
rules = policy.Rules()
@@ -105,7 +105,7 @@ class RulesTestCase(testtools.TestCase):
self.assertEqual(str(rules), exemplar)
-class PolicySetAndResetTestCase(testtools.TestCase):
+class PolicySetAndResetTestCase(utils.BaseTestCase):
def setUp(self):
super(PolicySetAndResetTestCase, self).setUp()
@@ -138,7 +138,7 @@ class FakeCheck(policy.BaseCheck):
return (target, creds)
-class CheckFunctionTestCase(testtools.TestCase):
+class CheckFunctionTestCase(utils.BaseTestCase):
def setUp(self):
super(CheckFunctionTestCase, self).setUp()
@@ -185,7 +185,7 @@ class CheckFunctionTestCase(testtools.TestCase):
self.fail("policy.check() failed to raise requested exception")
-class FalseCheckTestCase(testtools.TestCase):
+class FalseCheckTestCase(utils.BaseTestCase):
def test_str(self):
check = policy.FalseCheck()
@@ -197,7 +197,7 @@ class FalseCheckTestCase(testtools.TestCase):
self.assertEqual(check('target', 'creds'), False)
-class TrueCheckTestCase(testtools.TestCase):
+class TrueCheckTestCase(utils.BaseTestCase):
def test_str(self):
check = policy.TrueCheck()
@@ -214,7 +214,7 @@ class CheckForTest(policy.Check):
pass
-class CheckTestCase(testtools.TestCase):
+class CheckTestCase(utils.BaseTestCase):
def test_init(self):
check = CheckForTest('kind', 'match')
@@ -227,7 +227,7 @@ class CheckTestCase(testtools.TestCase):
self.assertEqual(str(check), 'kind:match')
-class NotCheckTestCase(testtools.TestCase):
+class NotCheckTestCase(utils.BaseTestCase):
def test_init(self):
check = policy.NotCheck('rule')
@@ -253,7 +253,7 @@ class NotCheckTestCase(testtools.TestCase):
rule.assert_called_once_with('target', 'cred')
-class OrCheckTestCase(testtools.TestCase):
+class OrCheckTestCase(utils.BaseTestCase):
def test_init(self):
check = policy.OrCheck(['rule1', 'rule2'])
@@ -295,7 +295,7 @@ class OrCheckTestCase(testtools.TestCase):
rules[1].assert_called_once_with('target', 'cred')
-class ParseCheckTestCase(testtools.TestCase):
+class ParseCheckTestCase(utils.BaseTestCase):
def test_false(self):
result = policy._parse_check('!')
@@ -338,7 +338,7 @@ class ParseCheckTestCase(testtools.TestCase):
policy._checks[None].assert_called_once_with('spam', 'handler')
-class ParseListRuleTestCase(testtools.TestCase):
+class ParseListRuleTestCase(utils.BaseTestCase):
def test_empty(self):
result = policy._parse_list_rule([])
@@ -408,7 +408,7 @@ class ParseListRuleTestCase(testtools.TestCase):
'((rule1 and rule2) or (rule3 and rule4))')
-class ParseTokenizeTestCase(testtools.TestCase):
+class ParseTokenizeTestCase(utils.BaseTestCase):
@mock.patch.object(policy, '_parse_check', lambda x: x)
def test_tokenize(self):
exemplar = ("(( ( ((() And)) or ) (check:%(miss)s) not)) "
@@ -428,7 +428,7 @@ class ParseTokenizeTestCase(testtools.TestCase):
self.assertEqual(result, expected)
-class ParseStateMetaTestCase(testtools.TestCase):
+class ParseStateMetaTestCase(utils.BaseTestCase):
def test_reducer(self):
@policy.reducer('a', 'b', 'c')
@policy.reducer('d', 'e', 'f')
@@ -462,7 +462,7 @@ class ParseStateMetaTestCase(testtools.TestCase):
self.fail("Unrecognized reducer discovered")
-class ParseStateTestCase(testtools.TestCase):
+class ParseStateTestCase(utils.BaseTestCase):
def test_init(self):
state = policy.ParseState()
@@ -627,7 +627,7 @@ class ParseStateTestCase(testtools.TestCase):
self.assertEqual(result, [('check', 'not check')])
-class ParseTextRuleTestCase(testtools.TestCase):
+class ParseTextRuleTestCase(utils.BaseTestCase):
def test_empty(self):
result = policy._parse_text_rule('')
@@ -653,7 +653,7 @@ class ParseTextRuleTestCase(testtools.TestCase):
mock_parse_tokenize.assert_called_once_with('test rule')
-class ParseRuleTestCase(testtools.TestCase):
+class ParseRuleTestCase(utils.BaseTestCase):
@mock.patch.object(policy, '_parse_text_rule', return_value='text rule')
@mock.patch.object(policy, '_parse_list_rule', return_value='list rule')
def test_parse_rule_string(self, mock_parse_list_rule,
@@ -674,7 +674,7 @@ class ParseRuleTestCase(testtools.TestCase):
mock_parse_list_rule.assert_called_once_with([['a'], ['list']])
-class CheckRegisterTestCase(testtools.TestCase):
+class CheckRegisterTestCase(utils.BaseTestCase):
@mock.patch.object(policy, '_checks', {})
def test_register_check(self):
class TestCheck(policy.Check):
@@ -693,7 +693,7 @@ class CheckRegisterTestCase(testtools.TestCase):
self.assertEqual(policy._checks, dict(spam=TestCheck))
-class RuleCheckTestCase(testtools.TestCase):
+class RuleCheckTestCase(utils.BaseTestCase):
@mock.patch.object(policy, '_rules', {})
def test_rule_missing(self):
check = policy.RuleCheck('rule', 'spam')
@@ -717,7 +717,7 @@ class RuleCheckTestCase(testtools.TestCase):
policy._rules['spam'].assert_called_once_with('target', 'creds')
-class RoleCheckTestCase(testtools.TestCase):
+class RoleCheckTestCase(utils.BaseTestCase):
def test_accept(self):
check = policy.RoleCheck('role', 'sPaM')
@@ -729,7 +729,7 @@ class RoleCheckTestCase(testtools.TestCase):
self.assertEqual(check('target', dict(roles=[])), False)
-class HttpCheckTestCase(testtools.TestCase):
+class HttpCheckTestCase(utils.BaseTestCase):
def decode_post_data(self, post_data):
result = {}
for item in post_data.split('&'):
@@ -775,7 +775,7 @@ class HttpCheckTestCase(testtools.TestCase):
))
-class GenericCheckTestCase(testtools.TestCase):
+class GenericCheckTestCase(utils.BaseTestCase):
def test_no_cred(self):
check = policy.GenericCheck('name', '%(name)s')
diff --git a/tests/unit/test_processutils.py b/tests/unit/test_processutils.py
index a140aaa..13d0846 100644
--- a/tests/unit/test_processutils.py
+++ b/tests/unit/test_processutils.py
@@ -15,14 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
import mock
from openstack.common import processutils
+from tests import utils
-class UtilsTest(testtools.TestCase):
+class UtilsTest(utils.BaseTestCase):
# NOTE(jkoelker) Moar tests from nova need to be ported. But they
# need to be mock'd out. Currently they requre actually
# running code.
@@ -32,7 +31,7 @@ class UtilsTest(testtools.TestCase):
hozer=True)
-class ProcessExecutionErrorTest(testtools.TestCase):
+class ProcessExecutionErrorTest(utils.BaseTestCase):
def test_defaults(self):
err = processutils.ProcessExecutionError()
diff --git a/tests/unit/test_setup.py b/tests/unit/test_setup.py
index 0632823..dfd8841 100644
--- a/tests/unit/test_setup.py
+++ b/tests/unit/test_setup.py
@@ -20,12 +20,12 @@ import sys
from tempfile import mkstemp
import fixtures
-import testtools
from openstack.common.setup import *
+from tests import utils
-class EmailTestCase(testtools.TestCase):
+class EmailTestCase(utils.BaseTestCase):
def test_str_dict_replace(self):
string = 'Johnnie T. Hozer'
@@ -34,7 +34,7 @@ class EmailTestCase(testtools.TestCase):
canonicalize_emails(string, mapping))
-class MailmapTestCase(testtools.TestCase):
+class MailmapTestCase(utils.BaseTestCase):
def setUp(self):
super(MailmapTestCase, self).setUp()
@@ -60,7 +60,7 @@ class MailmapTestCase(testtools.TestCase):
parse_mailmap(self.mailmap))
-class ParseRequirementsTest(testtools.TestCase):
+class ParseRequirementsTest(utils.BaseTestCase):
def setUp(self):
super(ParseRequirementsTest, self).setUp()
diff --git a/tests/unit/test_strutils.py b/tests/unit/test_strutils.py
index 88ab9c1..6995427 100644
--- a/tests/unit/test_strutils.py
+++ b/tests/unit/test_strutils.py
@@ -15,15 +15,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
import mock
from openstack.common import exception
from openstack.common import strutils
+from tests import utils
-class StrUtilsTest(testtools.TestCase):
+class StrUtilsTest(utils.BaseTestCase):
def test_bool_bool_from_string(self):
self.assertTrue(strutils.bool_from_string(True))
diff --git a/tests/unit/test_timeutils.py b/tests/unit/test_timeutils.py
index 0c3c7b4..42fc850 100644
--- a/tests/unit/test_timeutils.py
+++ b/tests/unit/test_timeutils.py
@@ -19,12 +19,12 @@ import datetime
import iso8601
import mock
-import testtools
from openstack.common import timeutils
+from tests import utils
-class TimeUtilsTest(testtools.TestCase):
+class TimeUtilsTest(utils.BaseTestCase):
def setUp(self):
super(TimeUtilsTest, self).setUp()
@@ -148,7 +148,7 @@ class TimeUtilsTest(testtools.TestCase):
timeutils.delta_seconds(before, after))
-class TestIso8601Time(testtools.TestCase):
+class TestIso8601Time(utils.BaseTestCase):
def _instaneous(self, timestamp, yr, mon, day, hr, min, sec, micro):
self.assertEquals(timestamp.year, yr)
diff --git a/tests/unit/test_uuidutils.py b/tests/unit/test_uuidutils.py
index 088f4b0..e9348e2 100644
--- a/tests/unit/test_uuidutils.py
+++ b/tests/unit/test_uuidutils.py
@@ -15,13 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
import uuid
from openstack.common import uuidutils
+from tests import utils
-class UUIDUtilsTest(testtools.TestCase):
+class UUIDUtilsTest(utils.BaseTestCase):
def test_generate_uuid(self):
uuid_string = uuidutils.generate_uuid()
diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py
index 17ecc31..b648fc4 100644
--- a/tests/unit/test_version.py
+++ b/tests/unit/test_version.py
@@ -20,7 +20,6 @@ import shutil
import StringIO
import sys
import tempfile
-import testtools
from openstack.common.cfg import *
from openstack.common import version
diff --git a/tests/unit/test_wsgi.py b/tests/unit/test_wsgi.py
index f40fba5..749d524 100644
--- a/tests/unit/test_wsgi.py
+++ b/tests/unit/test_wsgi.py
@@ -16,14 +16,14 @@
# under the License.
import mock
-import testtools
import webob
from openstack.common import exception
from openstack.common import wsgi
+from tests import utils
-class RequestTest(testtools.TestCase):
+class RequestTest(utils.BaseTestCase):
def test_content_type_missing(self):
request = wsgi.Request.blank('/tests/123', method='POST')
@@ -104,7 +104,7 @@ class RequestTest(testtools.TestCase):
self.assertEqual(result, "application/new_type")
-class ActionDispatcherTest(testtools.TestCase):
+class ActionDispatcherTest(utils.BaseTestCase):
def test_dispatch(self):
serializer = wsgi.ActionDispatcher()
@@ -127,7 +127,7 @@ class ActionDispatcherTest(testtools.TestCase):
'Two trousers')
-class ResponseHeadersSerializerTest(testtools.TestCase):
+class ResponseHeadersSerializerTest(utils.BaseTestCase):
def test_default(self):
serializer = wsgi.ResponseHeadersSerializer()
@@ -147,14 +147,14 @@ class ResponseHeadersSerializerTest(testtools.TestCase):
self.assertEqual(response.headers['X-Custom-Header'], '123')
-class DictSerializerTest(testtools.TestCase):
+class DictSerializerTest(utils.BaseTestCase):
def test_dispatch_default(self):
serializer = wsgi.DictSerializer()
self.assertEqual(serializer.serialize({}, 'NonExistantAction'), '')
-class XMLDictSerializerTest(testtools.TestCase):
+class XMLDictSerializerTest(utils.BaseTestCase):
def test_xml(self):
input_dict = dict(servers=dict(a=(2, 3)))
@@ -168,7 +168,7 @@ class XMLDictSerializerTest(testtools.TestCase):
self.assertEqual(result, expected_xml)
-class JSONDictSerializerTest(testtools.TestCase):
+class JSONDictSerializerTest(utils.BaseTestCase):
def test_json(self):
input_dict = dict(servers=dict(a=(2, 3)))
@@ -190,14 +190,14 @@ class JSONDictSerializerTest(testtools.TestCase):
self.assertEqual(result, expected_str)
-class TextDeserializerTest(testtools.TestCase):
+class TextDeserializerTest(utils.BaseTestCase):
def test_dispatch_default(self):
deserializer = wsgi.TextDeserializer()
self.assertEqual(deserializer.deserialize({}, 'update'), {})
-class JSONDeserializerTest(testtools.TestCase):
+class JSONDeserializerTest(utils.BaseTestCase):
def test_json(self):
data = """{"a": {
@@ -221,7 +221,7 @@ class JSONDeserializerTest(testtools.TestCase):
self.assertEqual(deserializer.deserialize(data), as_dict)
-class XMLDeserializerTest(testtools.TestCase):
+class XMLDeserializerTest(utils.BaseTestCase):
def test_xml(self):
xml = """
@@ -253,7 +253,7 @@ class XMLDeserializerTest(testtools.TestCase):
self.assertEqual(deserializer.deserialize(xml), as_dict)
-class RequestHeadersDeserializerTest(testtools.TestCase):
+class RequestHeadersDeserializerTest(utils.BaseTestCase):
def test_default(self):
deserializer = wsgi.RequestHeadersDeserializer()
@@ -270,7 +270,7 @@ class RequestHeadersDeserializerTest(testtools.TestCase):
self.assertEqual(deserializer.deserialize(req, 'update'), {'a': 'b'})
-class ResponseSerializerTest(testtools.TestCase):
+class ResponseSerializerTest(utils.BaseTestCase):
def setUp(self):
super(ResponseSerializerTest, self).setUp()
@@ -330,7 +330,7 @@ class ResponseSerializerTest(testtools.TestCase):
{}, 'application/unknown')
-class RequestDeserializerTest(testtools.TestCase):
+class RequestDeserializerTest(utils.BaseTestCase):
def setUp(self):
super(RequestDeserializerTest, self).setUp()
@@ -399,7 +399,7 @@ class RequestDeserializerTest(testtools.TestCase):
self.assertEqual(expected, deserialized)
-class ResourceTest(testtools.TestCase):
+class ResourceTest(utils.BaseTestCase):
def test_dispatch(self):
class Controller(object):
@@ -439,7 +439,7 @@ class ResourceTest(testtools.TestCase):
self.assertEqual(response.status, '415 Unsupported Media Type')
-class ServerTest(testtools.TestCase):
+class ServerTest(utils.BaseTestCase):
def test_run_server(self):
listen_patcher = mock.patch('eventlet.listen')
@@ -457,7 +457,7 @@ class ServerTest(testtools.TestCase):
server_patcher.stop()
-class WSGIServerTest(testtools.TestCase):
+class WSGIServerTest(utils.BaseTestCase):
def test_pool(self):
server = wsgi.Service('fake', 9000)
diff --git a/tests/utils.py b/tests/utils.py
index 26d22b0..3c749f6 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -18,6 +18,8 @@
"""Common utilities used in testing"""
import subprocess
+
+import fixtures
import testtools
from openstack.common import cfg
@@ -32,6 +34,7 @@ class BaseTestCase(testtools.TestCase):
super(BaseTestCase, self).setUp()
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.addCleanup(CONF.reset)
+ self.useFixture(fixtures.FakeLogger('openstack.common'))
def config(self, **kw):
"""