Use oslotest.base.BaseTestCase as test base class

Switch to BaseTestCase as base class for all Manila test classes.
This BaseTestCase class automatically uses the following fixtures:

 * fixtures.FakeLogger (only if needed)
 * fixtures.NestedTempfile
 * fixtures.TempHomeDir

so we don't have to explicit add them to our constructor.

Change-Id: I336d024f7008f5300e1882fa960a8e32439a9a70
This commit is contained in:
Thomas Bechtold 2014-12-28 16:03:50 +01:00
parent 0dd28ab401
commit 993e7489fa
2 changed files with 3 additions and 12 deletions

View File

@ -2,6 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
${PYTHON:-python} -m subunit.run discover -t ./ ./manila/tests $LISTOPT $IDOPTION ${PYTHON:-python} -m subunit.run discover -t ./ ./manila/tests $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE test_id_option=--load-list $IDFILE
test_list_option=--list test_list_option=--list

View File

@ -30,10 +30,9 @@ import mock
from oslo.config import cfg from oslo.config import cfg
from oslo.config import fixture as config_fixture from oslo.config import fixture as config_fixture
from oslo.messaging import conffixture as messaging_conffixture from oslo.messaging import conffixture as messaging_conffixture
from oslo.utils import timeutils
from oslo_concurrency import lockutils from oslo_concurrency import lockutils
import oslotest.base as base_test
import six import six
import testtools
from manila.db import migration from manila.db import migration
from manila.db.sqlalchemy import api as db_api from manila.db.sqlalchemy import api as db_api
@ -112,7 +111,7 @@ class StubOutForTesting(object):
self.parent.addCleanup(stub.stop) self.parent.addCleanup(stub.stop)
class TestCase(testtools.TestCase): class TestCase(base_test.BaseTestCase):
"""Test case base class for all unit tests.""" """Test case base class for all unit tests."""
def setUp(self): def setUp(self):
@ -122,15 +121,6 @@ class TestCase(testtools.TestCase):
conf_fixture.set_defaults(CONF) conf_fixture.set_defaults(CONF)
CONF([], default_config_files=[]) CONF([], default_config_files=[])
# NOTE(vish): We need a better method for creating fixtures for tests
# now that we have some required db setup for the system
# to work properly.
self.start = timeutils.utcnow()
self.log_fixture = self.useFixture(fixtures.FakeLogger())
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.TempHomeDir())
global _DB_CACHE global _DB_CACHE
if not _DB_CACHE: if not _DB_CACHE:
_DB_CACHE = Database( _DB_CACHE = Database(