From 262d0b66c3bcb82eadb663910ee21ded63e77a78 Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Wed, 17 Feb 2016 17:17:39 -0600 Subject: [PATCH] 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 --- .testr.conf | 3 --- keystone/tests/unit/core.py | 8 ++++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.testr.conf b/.testr.conf index 7469895480..20703b3589 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,8 +1,5 @@ [DEFAULT] 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 test_id_option=--load-list $IDFILE diff --git a/keystone/tests/unit/core.py b/keystone/tests/unit/core.py index 0b655f2640..05bea96338 100644 --- a/keystone/tests/unit/core.py +++ b/keystone/tests/unit/core.py @@ -34,11 +34,11 @@ from oslo_config import fixture as config_fixture from oslo_log import fixture as log_fixture from oslo_log import log from oslo_utils import timeutils -import oslotest.base as oslotest from oslotest import mockpatch from paste.deploy import loadwsgi import six from sqlalchemy import exc +import testtools from testtools import testcase # NOTE(ayoung) @@ -491,7 +491,7 @@ def create_user(api, domain_id, **kwargs): return user -class BaseTestCase(oslotest.BaseTestCase): +class BaseTestCase(testtools.TestCase): """Light weight base test class. This is a placeholder that will eventually go away once the @@ -502,6 +502,10 @@ class BaseTestCase(oslotest.BaseTestCase): def setUp(self): super(BaseTestCase, self).setUp() + + self.useFixture(fixtures.NestedTempfile()) + self.useFixture(fixtures.TempHomeDir()) + self.useFixture(mockpatch.PatchObject(sys, 'exit', side_effect=UnexpectedExit)) self.useFixture(log_fixture.get_logging_handle_error_fixture())