mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
test_classes: Rename and refactor 'tornado_redirected_to_list'.
This commit renames the 'tornado_redirected_to_list' context manager to 'capture_send_event_calls' to improve readability. It also refactors the function to yield a list of events instead of passing in a list data structure as a parameter and appending events to it.
This commit is contained in:
committed by
Tim Abbott
parent
a62fcb1fd9
commit
d96048b0af
@@ -1692,10 +1692,10 @@ Output:
|
||||
)
|
||||
|
||||
@contextmanager
|
||||
def tornado_redirected_to_list(
|
||||
self, lst: List[Mapping[str, Any]], expected_num_events: int
|
||||
) -> Iterator[None]:
|
||||
lst.clear()
|
||||
def capture_send_event_calls(
|
||||
self, expected_num_events: int
|
||||
) -> Iterator[List[Mapping[str, Any]]]:
|
||||
lst: List[Mapping[str, Any]] = []
|
||||
|
||||
# process_notification takes a single parameter called 'notice'.
|
||||
# lst.append takes a single argument called 'object'.
|
||||
@@ -1711,7 +1711,7 @@ Output:
|
||||
# never be sent in tests, and we would be unable to verify them. Hence, we use
|
||||
# this helper to make sure the `send_event` calls actually run.
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
yield
|
||||
yield lst
|
||||
|
||||
self.assert_length(lst, expected_num_events)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user