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.

transaction: Add 'savepoint=True' explicitly in tests, if used.

Prakhar Pratyush62b3e4907549
diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py
index fe935b2082f..55d620140cc 100644
--- a/zerver/lib/test_classes.py
+++ b/zerver/lib/test_classes.py
@@ -1462,10 +1462,10 @@ Output:
"invite_only": orjson.dumps(invite_only).decode(),
}
post_data.update(extra_post_data)
- # We wrap the API call with a 'transaction.atomic()' context
+ # We wrap the API call with a 'transaction.atomic' context
# manager as it helps us with NOT rolling back the entire
# test transaction due to error responses.
- with transaction.atomic():
+ with transaction.atomic(savepoint=True):
result = self.api_post(
user,
"/api/v1/users/me/subscriptions",
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index 85c645c5496..d676588f7a1 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -4124,7 +4124,7 @@ class SubscriptionRestApiTest(ZulipTestCase):
def thunk2() -> HttpResponse:
raise JsonableError("random failure")
- with transaction.atomic(), self.assertRaises(JsonableError):
+ with transaction.atomic(savepoint=True), self.assertRaises(JsonableError):
# The atomic() wrapper helps to avoid JsonableError breaking
# the test's transaction.
compose_views([thunk1, thunk2])