mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
models: Remove type prefixes from __str__ values.
The Django convention is for __repr__ to include the type and __str__
to omit it. In fact its default __repr__ implementation for models
automatically adds a type prefix to __str__, which has resulted in the
type being duplicated:
>>> UserProfile.objects.first()
<UserProfile: <UserProfile: emailgateway@zulip.com <Realm: zulipinternal 1>>>
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
f66136fcc2
commit
2d9b2a2a05
@@ -552,7 +552,7 @@ class RecipientTest(ZulipTestCase):
|
||||
type_id=stream.id,
|
||||
type=Recipient.STREAM,
|
||||
)
|
||||
self.assertEqual(str(recipient), f"<Recipient: Verona ({stream.id}, {Recipient.STREAM})>")
|
||||
self.assertEqual(repr(recipient), f"<Recipient: Verona ({stream.id}, {Recipient.STREAM})>")
|
||||
|
||||
|
||||
class StreamAdminTest(ZulipTestCase):
|
||||
@@ -5111,11 +5111,11 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
)
|
||||
subscription = self.get_subscription(user_profile, invite_streams[0])
|
||||
|
||||
with mock.patch("zerver.models.Recipient.__str__", return_value="recip"):
|
||||
with mock.patch("zerver.models.Recipient.__repr__", return_value="recip"):
|
||||
self.assertEqual(
|
||||
str(subscription),
|
||||
repr(subscription),
|
||||
"<Subscription: "
|
||||
f"<UserProfile: {user_profile.email} {user_profile.realm}> -> recip>",
|
||||
f"<UserProfile: {user_profile.email} {user_profile.realm!r}> -> recip>",
|
||||
)
|
||||
|
||||
self.assertIsNone(subscription.desktop_notifications)
|
||||
|
||||
Reference in New Issue
Block a user