Add mock.patch.stopall cleanup handler to base test class

There are a few places where an object is mocked but never stopped.
Such a thing can cause unexpected behavior for other tests influeced by
the mock.  To be on the safe side, this patch adds a cleanup handler
that always stops all mocked objects after test is finished.

Change-Id: I3ae3daa529e864f139e200d7943288d7c931e86b
This commit is contained in:
Jakub Libosvar 2019-03-15 09:56:28 +00:00
parent 9a2ba5e7fb
commit c52e53b1bc

View File

@ -15,9 +15,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from oslotest import base
class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests."""
"""Test case base class for all unit and functional tests."""
def setUp(self):
super(TestCase, self).setUp()
self.addCleanup(mock.patch.stopall)