Skip to content

Commit

Permalink
zerver/lib/test_helpers.py: Wrap function in lambda.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sharmaeklavya2 authored and timabbott committed Feb 7, 2017
1 parent b7635db commit 415ce9c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zerver/lib/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 415ce9c

Please sign in to comment.