From 9e49a93df34edea94753c2291e9d7eb4e24ed2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Mon, 12 Aug 2019 16:25:03 +0200 Subject: [PATCH] Fix event handler pytest.raises test cases --- .../event_handling/test_event_handler.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tfw/internals/event_handling/test_event_handler.py b/tfw/internals/event_handling/test_event_handler.py index 03f4141..6398627 100644 --- a/tfw/internals/event_handling/test_event_handler.py +++ b/tfw/internals/event_handling/test_event_handler.py @@ -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):