diff --git a/keystoneclient/tests/unit/utils.py b/keystoneclient/tests/unit/utils.py index 69333763c..22745190a 100644 --- a/keystoneclient/tests/unit/utils.py +++ b/keystoneclient/tests/unit/utils.py @@ -16,8 +16,8 @@ import time import uuid import fixtures -import mock from oslo_serialization import jsonutils +from oslotest import mockpatch import requests from requests_mock.contrib import fixture import six @@ -43,15 +43,11 @@ class TestCase(testtools.TestCase): def setUp(self): super(TestCase, self).setUp() self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG)) - self.time_patcher = mock.patch.object(time, 'time', lambda: 1234) - self.time_patcher.start() + self.time_patcher = self.useFixture( + mockpatch.PatchObject(time, 'time', lambda: 1234)).mock self.requests_mock = self.useFixture(fixture.Fixture()) - def tearDown(self): - self.time_patcher.stop() - super(TestCase, self).tearDown() - def stub_url(self, method, parts=None, base_url=None, json=None, **kwargs): if not base_url: base_url = self.TEST_URL diff --git a/keystoneclient/tests/unit/v2_0/test_shell.py b/keystoneclient/tests/unit/v2_0/test_shell.py index 85bbca5f0..6210cfbed 100644 --- a/keystoneclient/tests/unit/v2_0/test_shell.py +++ b/keystoneclient/tests/unit/v2_0/test_shell.py @@ -39,7 +39,7 @@ class ShellTests(utils.TestCase): super(ShellTests, self).setUp() - self.old_environment = os.environ.copy() + self.addCleanup(setattr, os, 'environ', os.environ.copy()) os.environ = { 'OS_USERNAME': DEFAULT_USERNAME, 'OS_PASSWORD': DEFAULT_PASSWORD, @@ -58,10 +58,6 @@ class ShellTests(utils.TestCase): self.stub_auth(json=self.token, base_url=DEFAULT_AUTH_URL) - def tearDown(self): - os.environ = self.old_environment - super(ShellTests, self).tearDown() - def run_command(self, cmd): orig = sys.stdout try: