Cleanup time patching
Rather than create a mock and have to stop it, use fixtures.MockPatchObject since it encapsulates the cleanup. Change-Id: I431c480c9bb8bed07a108f088ac9d91872777754
This commit is contained in:
@@ -16,7 +16,6 @@ import time
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import requests
|
||||
from requests_mock.contrib import fixture
|
||||
import six
|
||||
@@ -42,15 +41,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()
|
||||
|
||||
fixtures.MockPatchObject(time, 'time', lambda: 1234)
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user