tests: uses oslotest as the test base

oslotest's base will add mock.patch.stopall, so we don't have to.

Change-Id: If13a465000648dfbf1e229a3b8d765e8b3204db4
This commit is contained in:
Claudiu Belu 2018-08-01 06:50:20 -07:00
parent f82d74ff1a
commit 8dd2910195
2 changed files with 4 additions and 3 deletions

View File

@ -34,10 +34,10 @@ from nova.tests.unit import conf_fixture
from nova.tests.unit import policy_fixture from nova.tests.unit import policy_fixture
from oslo_log.fixture import logging_error as log_fixture from oslo_log.fixture import logging_error as log_fixture
from oslo_log import log as logging from oslo_log import log as logging
from oslotest import base
from oslotest import mock_fixture from oslotest import mock_fixture
from oslotest import moxstubout from oslotest import moxstubout
import six import six
import testtools
import compute_hyperv.nova.conf import compute_hyperv.nova.conf
@ -78,7 +78,7 @@ _patch_mock_to_raise_for_invalid_assert_calls()
mock_fixture.patch_mock_module() mock_fixture.patch_mock_module()
class NoDBTestCase(testtools.TestCase): class NoDBTestCase(base.BaseTestCase):
"""Test case base class for all unit tests. """Test case base class for all unit tests.
Due to the slowness of DB access, please consider deriving from Due to the slowness of DB access, please consider deriving from

View File

@ -32,9 +32,9 @@ class HyperVBaseTestCase(test.NoDBTestCase):
utilsfactory_patcher = mock.patch.object( utilsfactory_patcher = mock.patch.object(
utilsfactory, '_get_class', HyperVBaseTestCase._mock_get_class) utilsfactory, '_get_class', HyperVBaseTestCase._mock_get_class)
utilsfactory_patcher.start() utilsfactory_patcher.start()
self.addCleanup(utilsfactory_patcher.stop)
self._patch_autospec_classes() self._patch_autospec_classes()
self.addCleanup(mock.patch.stopall)
@staticmethod @staticmethod
def _mock_get_class(class_type, *args, **kwargs): def _mock_get_class(class_type, *args, **kwargs):
@ -51,6 +51,7 @@ class HyperVBaseTestCase(test.NoDBTestCase):
'.'.join([class_type.__module__, class_type.__name__]), '.'.join([class_type.__module__, class_type.__name__]),
mocked_class) mocked_class)
patcher.start() patcher.start()
self.addCleanup(patcher.stop)
class MonotonicTestCase(test.NoDBTestCase): class MonotonicTestCase(test.NoDBTestCase):