summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-01-23 02:48:21 -0500
committerMonty Taylor <mordred@inaugust.com>2013-01-24 16:30:22 +1100
commit60f70b0b3996365a889546eb1e4c5c7edc4cfde0 (patch)
tree69bdf81b14944f3400182fd508538012570f5e3e
parenta14c212795b59c67d6e5cde052e659743eae2b9f (diff)
downloadoslo-60f70b0b3996365a889546eb1e4c5c7edc4cfde0.tar.gz
oslo-60f70b0b3996365a889546eb1e4c5c7edc4cfde0.tar.xz
oslo-60f70b0b3996365a889546eb1e4c5c7edc4cfde0.zip
Replaced direct usage of stubout with BaseTestCase.
BaseTestCase properly hooks stubout into fixtures. Just use that. Part of blueprint grizzly-testtools. Change-Id: I4bf6b92b9b16d051d8c6ecaf52cf70925848ed8c
-rw-r--r--tests/unit/rpc/test_kombu.py4
-rw-r--r--tests/unit/rpc/test_proxy.py9
-rw-r--r--tests/unit/scheduler/test_host_filters.py9
-rw-r--r--tests/unit/test_cfg.py11
-rw-r--r--tests/unit/test_rootwrap.py6
-rw-r--r--tests/unit/test_version.py13
6 files changed, 13 insertions, 39 deletions
diff --git a/tests/unit/rpc/test_kombu.py b/tests/unit/rpc/test_kombu.py
index c8e41ff..d777a8a 100644
--- a/tests/unit/rpc/test_kombu.py
+++ b/tests/unit/rpc/test_kombu.py
@@ -26,11 +26,8 @@ import contextlib
import logging
import testtools
-import stubout
-
from openstack.common import cfg
from openstack.common import exception
-from openstack.common.fixture import moxstubout
from openstack.common.rpc import amqp as rpc_amqp
from openstack.common.rpc import common as rpc_common
from tests.unit.rpc import common
@@ -69,7 +66,6 @@ def _raise_exc_stub(stubs, times, obj, method, exc_msg,
class KombuStubs:
@staticmethod
def setUp(self):
- self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
if kombu:
self.config(fake_rabbit=True)
self.config(rpc_response_timeout=5)
diff --git a/tests/unit/rpc/test_proxy.py b/tests/unit/rpc/test_proxy.py
index ae05b3f..64eb008 100644
--- a/tests/unit/rpc/test_proxy.py
+++ b/tests/unit/rpc/test_proxy.py
@@ -19,20 +19,15 @@ Unit Tests for rpc.proxy
"""
import copy
-import stubout
-import testtools
from openstack.common import context
from openstack.common.fixture import moxstubout
from openstack.common import rpc
from openstack.common.rpc import proxy
+from tests import utils
-class RpcProxyTestCase(testtools.TestCase):
-
- def setUp(self):
- super(RpcProxyTestCase, self).setUp()
- self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
+class RpcProxyTestCase(utils.BaseTestCase):
def _test_rpc_method(self, rpc_method, has_timeout=False, has_retval=False,
server_params=None, supports_topic_override=True):
diff --git a/tests/unit/scheduler/test_host_filters.py b/tests/unit/scheduler/test_host_filters.py
index 999e1c0..7d3a0e4 100644
--- a/tests/unit/scheduler/test_host_filters.py
+++ b/tests/unit/scheduler/test_host_filters.py
@@ -15,14 +15,12 @@
Tests For Scheduler Host Filters.
"""
-import stubout
-import testtools
-
from openstack.common import context
from openstack.common import jsonutils
from openstack.common.scheduler import filters
from openstack.common.scheduler.filters import extra_specs_ops
from tests.unit.scheduler import fake_hosts as fakes
+from tests import utils
class TestFilter(filters.BaseHostFilter):
@@ -34,7 +32,7 @@ class TestBogusFilter(object):
pass
-class ExtraSpecsOpsTestCase(testtools.TestCase):
+class ExtraSpecsOpsTestCase(utils.BaseTestCase):
def _do_extra_specs_ops_test(self, value, req, matches):
assertion = self.assertTrue if matches else self.assertFalse
assertion(extra_specs_ops.match(value, req))
@@ -220,12 +218,11 @@ class ExtraSpecsOpsTestCase(testtools.TestCase):
matches=False)
-class HostFiltersTestCase(testtools.TestCase):
+class HostFiltersTestCase(utils.BaseTestCase):
"""Test case for host filters."""
def setUp(self):
super(HostFiltersTestCase, self).setUp()
- self.stubs = stubout.StubOutForTesting()
self.context = context.RequestContext('fake', 'fake')
self.json_query = jsonutils.dumps(
['and', ['>=', '$free_ram_mb', 1024],
diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py
index 7e12a03..07de853 100644
--- a/tests/unit/test_cfg.py
+++ b/tests/unit/test_cfg.py
@@ -21,14 +21,12 @@ import sys
import tempfile
import fixtures
-import stubout
-import testtools
from openstack.common.cfg import *
-from openstack.common.fixture import moxstubout
+from tests import utils
-class ExceptionsTestCase(testtools.TestCase):
+class ExceptionsTestCase(utils.BaseTestCase):
def test_error(self):
msg = str(Error('foobar'))
@@ -75,7 +73,7 @@ class ExceptionsTestCase(testtools.TestCase):
self.assertEquals(msg, 'Failed to parse foo: foobar')
-class BaseTestCase(testtools.TestCase):
+class BaseTestCase(utils.BaseTestCase):
class TestConfigOpts(ConfigOpts):
def __call__(self, args=None):
@@ -92,7 +90,6 @@ class BaseTestCase(testtools.TestCase):
self.conf = self.TestConfigOpts()
self.tempdirs = []
- self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
def create_tempfiles(self, files, ext='.conf'):
tempfiles = []
@@ -1567,7 +1564,7 @@ class OptDumpingTestCase(BaseTestCase):
])
-class ConfigParserTestCase(testtools.TestCase):
+class ConfigParserTestCase(utils.BaseTestCase):
def test_no_section(self):
with tempfile.NamedTemporaryFile() as tmpfile:
tmpfile.write('foo = bar')
diff --git a/tests/unit/test_rootwrap.py b/tests/unit/test_rootwrap.py
index 30708d3..e2b4697 100644
--- a/tests/unit/test_rootwrap.py
+++ b/tests/unit/test_rootwrap.py
@@ -18,19 +18,17 @@ import ConfigParser
import logging
import logging.handlers
import os
-import stubout
import subprocess
-import testtools
from openstack.common.rootwrap import filters
from openstack.common.rootwrap import wrapper
+from tests import utils
-class RootwrapTestCase(testtools.TestCase):
+class RootwrapTestCase(utils.BaseTestCase):
def setUp(self):
super(RootwrapTestCase, self).setUp()
- self.stubs = stubout.StubOutForTesting()
self.filters = [
filters.RegExpFilter("/bin/ls", "root", 'ls', '/[a-z]+'),
filters.CommandFilter("/usr/bin/foo_bar_not_exist", "root"),
diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py
index 3b2f3db..17ecc31 100644
--- a/tests/unit/test_version.py
+++ b/tests/unit/test_version.py
@@ -22,21 +22,12 @@ import sys
import tempfile
import testtools
-import stubout
-
from openstack.common.cfg import *
from openstack.common import version
+from tests import utils
-class BaseTestCase(testtools.TestCase):
-
- def setUp(self):
- super(BaseTestCase, self).setUp()
- self.stubs = stubout.StubOutForTesting()
- self.addCleanup(self.stubs.UnsetAll)
-
-
-class DeferredVersionTestCase(BaseTestCase):
+class DeferredVersionTestCase(utils.BaseTestCase):
def setUp(self):
super(DeferredVersionTestCase, self).setUp()