From 8dd291019570c1a2b4f5b61cbebb50f166accf49 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Wed, 1 Aug 2018 06:50:20 -0700 Subject: [PATCH] tests: uses oslotest as the test base oslotest's base will add mock.patch.stopall, so we don't have to. Change-Id: If13a465000648dfbf1e229a3b8d765e8b3204db4 --- compute_hyperv/tests/test.py | 4 ++-- compute_hyperv/tests/unit/test_base.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compute_hyperv/tests/test.py b/compute_hyperv/tests/test.py index 1fac60f9..41609ae9 100644 --- a/compute_hyperv/tests/test.py +++ b/compute_hyperv/tests/test.py @@ -34,10 +34,10 @@ from nova.tests.unit import conf_fixture from nova.tests.unit import policy_fixture from oslo_log.fixture import logging_error as log_fixture from oslo_log import log as logging +from oslotest import base from oslotest import mock_fixture from oslotest import moxstubout import six -import testtools import compute_hyperv.nova.conf @@ -78,7 +78,7 @@ _patch_mock_to_raise_for_invalid_assert_calls() mock_fixture.patch_mock_module() -class NoDBTestCase(testtools.TestCase): +class NoDBTestCase(base.BaseTestCase): """Test case base class for all unit tests. Due to the slowness of DB access, please consider deriving from diff --git a/compute_hyperv/tests/unit/test_base.py b/compute_hyperv/tests/unit/test_base.py index 6513c204..3599adfc 100644 --- a/compute_hyperv/tests/unit/test_base.py +++ b/compute_hyperv/tests/unit/test_base.py @@ -32,9 +32,9 @@ class HyperVBaseTestCase(test.NoDBTestCase): utilsfactory_patcher = mock.patch.object( utilsfactory, '_get_class', HyperVBaseTestCase._mock_get_class) utilsfactory_patcher.start() + self.addCleanup(utilsfactory_patcher.stop) self._patch_autospec_classes() - self.addCleanup(mock.patch.stopall) @staticmethod def _mock_get_class(class_type, *args, **kwargs): @@ -51,6 +51,7 @@ class HyperVBaseTestCase(test.NoDBTestCase): '.'.join([class_type.__module__, class_type.__name__]), mocked_class) patcher.start() + self.addCleanup(patcher.stop) class MonotonicTestCase(test.NoDBTestCase):