mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-24 02:41:33 +00:00
Fix event handler pytest.raises test cases
This commit is contained in:
parent
0549c5e4c8
commit
9e49a93df3
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user