Stop using tearDown
tearDown doesn't get called when there's an exception in setUp, which can cause issues with test stability and isolation, so better to avoid it. Change-Id: I5ca2d84bcf82f4c88af26b4c582b0f23264a959c
This commit is contained in:
parent
f249332bb6
commit
350b7951d0
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user