Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_helpers: Fix exception safety of stdout_suppressed.

Anders Kaseorg96159688c2d7
diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py
index 3c1d62875b3..4ce95571af8 100644
--- a/zerver/lib/test_helpers.py
+++ b/zerver/lib/test_helpers.py
@@ -186,8 +186,10 @@ def stdout_suppressed() -> Iterator[IO[str]]:
with open(os.devnull, "a") as devnull:
stdout, sys.stdout = sys.stdout, devnull
- yield stdout
- sys.stdout = stdout
+ try:
+ yield stdout
+ finally:
+ sys.stdout = stdout
def reset_emails_in_zulip_realm() -> None: