Fix event handler pytest.raises test cases

This commit is contained in:
Kristóf Tóth 2019-08-12 16:25:03 +02:00
parent 0549c5e4c8
commit 9e49a93df3

View File

@ -89,9 +89,9 @@ def test_build_from_object(test_keys, test_msg):
assert mock_eh.connector is eh.connector
with pytest.raises(RuntimeError) as err:
eh.connector.simulate_message(test_msg)
msg, keys = err.args
assert msg == test_msg
assert keys == test_keys
msg, keys = err.value.args
assert msg == test_msg
assert keys == test_keys
assert not mock_eh.cleaned_up
eh.stop()
assert mock_eh.cleaned_up
@ -119,16 +119,15 @@ def test_build_from_simple_object(test_keys, test_msg):
class SimpleMockEventHandler:
# pylint: disable=no-self-use
def handle_event(self, message, connector):
raise RuntimeError(message, connector)
raise RuntimeError(message)
mock_eh = SimpleMockEventHandler()
eh = MockEventHandlerFactory().build(mock_eh, keys=test_keys)
with pytest.raises(RuntimeError) as err:
eh.connector.simulate_message(test_msg)
msg, keys = err.args
assert msg == test_msg
assert keys == test_keys
msg = err.value.args[0]
assert msg == test_msg
def test_build_from_callable(test_keys, test_msg):
@ -156,9 +155,9 @@ def test_build_from_function(test_keys, test_msg):
assert eh.connector.keys == test_keys
with pytest.raises(RuntimeError) as err:
eh.connector.simulate_message(test_msg)
msg, keys = err.args
assert msg == test_msg
assert keys == test_keys
msg, keys = err.value.args
assert msg == test_msg
assert keys == test_keys
def test_build_from_lambda(test_keys, test_msg):