ruff: Fix SIM117 Use a single with statement with multiple contexts.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-07-14 11:30:42 -07:00
committed by Tim Abbott
parent b0f144327d
commit b96feb34f6
47 changed files with 1380 additions and 1141 deletions

View File

@@ -338,10 +338,12 @@ class MutedTopicsTests(ZulipTestCase):
mock_date_muted = datetime(2020, 1, 1, tzinfo=timezone.utc).timestamp()
with self.capture_send_event_calls(expected_num_events=2) as events:
with time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False):
result = self.api_post(user, url, data)
self.assert_json_success(result)
with (
self.capture_send_event_calls(expected_num_events=2) as events,
time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False),
):
result = self.api_post(user, url, data)
self.assert_json_success(result)
self.assertTrue(
topic_has_visibility_policy(
@@ -404,10 +406,12 @@ class MutedTopicsTests(ZulipTestCase):
mock_date_mute_removed = datetime(2020, 1, 1, tzinfo=timezone.utc).timestamp()
with self.capture_send_event_calls(expected_num_events=2) as events:
with time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False):
result = self.api_post(user, url, data)
self.assert_json_success(result)
with (
self.capture_send_event_calls(expected_num_events=2) as events,
time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False),
):
result = self.api_post(user, url, data)
self.assert_json_success(result)
self.assertFalse(
topic_has_visibility_policy(
@@ -553,10 +557,12 @@ class UnmutedTopicsTests(ZulipTestCase):
mock_date_unmuted = datetime(2020, 1, 1, tzinfo=timezone.utc).timestamp()
with self.capture_send_event_calls(expected_num_events=2) as events:
with time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False):
result = self.api_post(user, url, data)
self.assert_json_success(result)
with (
self.capture_send_event_calls(expected_num_events=2) as events,
time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False),
):
result = self.api_post(user, url, data)
self.assert_json_success(result)
self.assertTrue(
topic_has_visibility_policy(
@@ -619,10 +625,12 @@ class UnmutedTopicsTests(ZulipTestCase):
mock_date_unmute_removed = datetime(2020, 1, 1, tzinfo=timezone.utc).timestamp()
with self.capture_send_event_calls(expected_num_events=2) as events:
with time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False):
result = self.api_post(user, url, data)
self.assert_json_success(result)
with (
self.capture_send_event_calls(expected_num_events=2) as events,
time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False),
):
result = self.api_post(user, url, data)
self.assert_json_success(result)
self.assertFalse(
topic_has_visibility_policy(