summaryrefslogtreecommitdiff
path: root/nova/test.py
diff options
context:
space:
mode:
authorEric Fried <openstack@fried.cc>2019-09-27 11:28:17 -0500
committerEric Fried <openstack@fried.cc>2019-11-22 22:38:22 +0000
commitccf7eabdf8375daad33e9c6164c0e302a0ab8e15 (patch)
treec48a943f251acd2164f1739c167b41d8866ec954 /nova/test.py
parenta0398278765f2854595bfa8e232ae4b9a6860aaf (diff)
downloadnova-ccf7eabdf8375daad33e9c6164c0e302a0ab8e15.tar.gz
test cleanup: Make base TestCase subclass oslotest
oslotest.base.BaseTestCase already sets up many of the fixtures we want from nova.test.TestCase, so inherit from it and remove those setups. Note that oslotest has a logger fixture, but nova's is significantly different, so we preserve the latter. Fortunately, oslotest provides a granny switch to disable its logger fixture -- the OS_LOG_CAPTURE env var -- so we explicitly do that, even though it's not on in our tox.ini, in case we accidentally run in an env where that's enabled. Change-Id: Ic61c3db824ec811336423bd956f2f2f03e02d21e
Diffstat (limited to 'nova/test.py')
-rw-r--r--nova/test.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/nova/test.py b/nova/test.py
index 5f20110a36..fccfd1772d 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -45,10 +45,9 @@ from oslo_serialization import jsonutils
from oslo_utils.fixture import uuidsentinel as uuids
from oslo_utils import timeutils
from oslo_versionedobjects import fixture as ovo_fixture
+from oslotest import base
from oslotest import mock_fixture
from oslotest import moxstubout
-from oslotest import output
-from oslotest import timeout
import six
from six.moves import builtins
import testtools
@@ -150,7 +149,7 @@ class NovaExceptionReraiseFormatError(object):
NovaExceptionReraiseFormatError.patch()
-class TestCase(testtools.TestCase):
+class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests.
Due to the slowness of DB access, please consider deriving from
@@ -174,25 +173,18 @@ class TestCase(testtools.TestCase):
# base class when USES_DB is True.
NUMBER_OF_CELLS = 1
- TIMEOUT_SCALING_FACTOR = 1
-
def setUp(self):
"""Run before each test method to initialize test environment."""
- super(TestCase, self).setUp()
- # The Timeout fixture picks up env.OS_TEST_TIMEOUT, defaulting to 0.
- self.useFixture(timeout.Timeout(
- scaling_factor=self.TIMEOUT_SCALING_FACTOR))
+ # Ensure BaseTestCase's ConfigureLogging fixture is disabled since
+ # we're using our own (StandardLogging).
+ with fixtures.EnvironmentVariable('OS_LOG_CAPTURE', '0'):
+ super(TestCase, self).setUp()
self.useFixture(nova_fixtures.OpenStackSDKFixture())
- self.useFixture(fixtures.NestedTempfile())
- self.useFixture(fixtures.TempHomeDir())
self.useFixture(log_fixture.get_logging_handle_error_fixture())
- self.output = self.useFixture(output.CaptureOutput())
-
- self.stdlog = nova_fixtures.StandardLogging()
- self.useFixture(self.stdlog)
+ self.stdlog = self.useFixture(nova_fixtures.StandardLogging())
# NOTE(sdague): because of the way we were using the lock
# wrapper we ended up with a lot of tests that started