From 415ce9c312bc59e4e58ccf4d93b63658d5a0597d Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Wed, 1 Feb 2017 14:18:47 +0530 Subject: [PATCH] zerver/lib/test_helpers.py: Wrap function in lambda. Wrap `list.append` in a lambda before assigning it to event_queue.process_notification to prevent errors when event_queue.process_notification is used with keyword arguments. This also removes an error message by mypy 0.4.7. --- zerver/lib/test_helpers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index 88f4bfa4bc39a..a5e181e1d8c1c 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -89,7 +89,12 @@ def simulated_queue_client(client): def tornado_redirected_to_list(lst): # type: (List[Mapping[str, Any]]) -> Iterator[None] real_event_queue_process_notification = event_queue.process_notification - event_queue.process_notification = lst.append + event_queue.process_notification = lambda notice: lst.append(notice) + # process_notification takes a single parameter called 'notice'. + # lst.append takes a single argument called 'object'. + # Some code might call process_notification using keyword arguments, + # so mypy doesn't allow assigning lst.append to process_notification + # So explicitly change parameter name to 'notice' to work around this problem yield event_queue.process_notification = real_event_queue_process_notification