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.

tests: Fix some instances of logged in session polluting test state.

Mateusz Manderaec5e12ef4ee0
diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py
index a4782aa2698..93e9313dcd4 100644
--- a/zerver/tests/test_message_send.py
+++ b/zerver/tests/test_message_send.py
@@ -2315,6 +2315,10 @@ class TestCrossRealmPMs(ZulipTestCase):
def create_user(self, email: str) -> UserProfile:
subdomain = email.split("@")[1]
self.register(email, "test", subdomain=subdomain)
+ # self.register has the side-effect of ending up with a logged in session
+ # for the new user. We don't want that in these tests.
+ self.logout()
+
return get_user(email, get_realm(subdomain))
@override_settings(
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
index 958e0823807..fca642498c2 100644
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -4290,6 +4290,11 @@ class UserSignUpTest(InviteUserBase):
hamlet_in_zulip.tutorial_status = UserProfile.TUTORIAL_FINISHED
hamlet_in_zulip.save()
+ # Now we'll be making requests to another subdomain, so we need to logout
+ # to avoid polluting the session in the test environment by still being
+ # logged in.
+ self.logout()
+
result = self.client_post("/accounts/home/", {"email": email}, subdomain=subdomain)
self.assertEqual(result.status_code, 302)
result = self.client_get(result["Location"], subdomain=subdomain)
diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.py
index 08fb5664986..47cfa077b49 100644
--- a/zerver/tests/test_upload.py
+++ b/zerver/tests/test_upload.py
@@ -561,6 +561,9 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
password = initial_password(email)
if password is not None:
self.register(email, password, subdomain=realm_id)
+ # self.register has the side-effect of ending up with a logged in session
+ # for the new user. We don't want that in these tests.
+ self.logout()
return get_user_by_delivery_email(email, get_realm(realm_id))
test_subdomain = "uploadtest.example.com"