[Tests] Fix unexpected tox output of SomeError exception

This suppresses traceback of SomeError exception raised in
tests.unit.deployment.test_engine.EngineTestCase:

    Traceback (most recent call last):
      File "tests/unit/deployment/test_engine.py", line 198,
      in context_with_error
	raise error
    SomeError

This output does not impact tests result but clogs
tox messages

Change-Id: I78ca06ec33c971129185389bc9a6d6321718817d
This commit is contained in:
Alexander Maretskiy 2016-04-11 15:00:02 +03:00
parent a088bfd53a
commit 0a1ac85e25

View File

@ -184,25 +184,18 @@ class EngineTestCase(test.TestCase):
@mock.patch.object(FakeDeployment, "update_status")
def _assert_changed_status_on_error(self, initial, final,
mock_fake_deployment_update_status):
# NOTE(akscram): The assertRaises of testtools can't be used as
# a context manager in python26:
# with self.assertRaises(SomeError):
# with engine as deployer:
# raise SomeError()
# instead of:
# self.assertRaises(SomeError,
# context_with_error,
# SomeError(), engine)
def context_with_error(error, manager):
with manager:
raise error
class SomeError(Exception):
pass
def context_with_error(manager):
with mock.patch("traceback.print_exception"):
with manager:
raise SomeError()
deployment = make_fake_deployment(status=initial)
engine = FakeEngine(deployment)
self.assertRaises(SomeError, context_with_error, SomeError(), engine)
self.assertRaises(SomeError, context_with_error, engine)
mock_fake_deployment_update_status.assert_called_once_with(final)
self.assertFalse(engine.cleanuped)
self.assertFalse(engine.deployed)