Stop using oslotest.BaseTestCase

oslotest.BaseTestCase is going to be deprecated / removed in favor of using
the provided fixtures. oslotest.BaseTestCase does unnatural things with mock
cleanup that can't be fixed in a backwards-compatible way and we don't want
this odd cleanup or deprecation affecting our tests. See [1].

oslotest.BaseTestCase set up some fixtures that keystone didn't use:

 - timeout.Timeout
 - output.CaptureOutput
 - oslotest.log.ConfigureLogging

[1] https://review.openstack.org/#/c/280757/

Change-Id: I5d926fba83f0390fe06e75614d85d87d2cb9f285
This commit is contained in:
Brant Knudson 2016-02-17 17:17:39 -06:00
parent 3060a6b340
commit 262d0b66c3
2 changed files with 6 additions and 5 deletions

View File

@ -1,8 +1,5 @@
[DEFAULT] [DEFAULT]
test_command= test_command=
OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./keystone/tests/unit} $LISTOPT $IDOPTION ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./keystone/tests/unit} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE test_id_option=--load-list $IDFILE

View File

@ -34,11 +34,11 @@ from oslo_config import fixture as config_fixture
from oslo_log import fixture as log_fixture from oslo_log import fixture as log_fixture
from oslo_log import log from oslo_log import log
from oslo_utils import timeutils from oslo_utils import timeutils
import oslotest.base as oslotest
from oslotest import mockpatch from oslotest import mockpatch
from paste.deploy import loadwsgi from paste.deploy import loadwsgi
import six import six
from sqlalchemy import exc from sqlalchemy import exc
import testtools
from testtools import testcase from testtools import testcase
# NOTE(ayoung) # NOTE(ayoung)
@ -491,7 +491,7 @@ def create_user(api, domain_id, **kwargs):
return user return user
class BaseTestCase(oslotest.BaseTestCase): class BaseTestCase(testtools.TestCase):
"""Light weight base test class. """Light weight base test class.
This is a placeholder that will eventually go away once the This is a placeholder that will eventually go away once the
@ -502,6 +502,10 @@ class BaseTestCase(oslotest.BaseTestCase):
def setUp(self): def setUp(self):
super(BaseTestCase, self).setUp() super(BaseTestCase, self).setUp()
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.TempHomeDir())
self.useFixture(mockpatch.PatchObject(sys, 'exit', self.useFixture(mockpatch.PatchObject(sys, 'exit',
side_effect=UnexpectedExit)) side_effect=UnexpectedExit))
self.useFixture(log_fixture.get_logging_handle_error_fixture()) self.useFixture(log_fixture.get_logging_handle_error_fixture())