From d54cb3c59d709c018e95ba01c7a3877e76652e7d Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Tue, 18 Apr 2017 17:09:22 -0700 Subject: [PATCH] Improve Account.repr() (#4325) * Include more detail in Account's repr. In particular, regr and meta. * Fix test. * Review feedback. * Lint * Test prefix only. --- certbot/account.py | 3 ++- certbot/tests/account_test.py | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/certbot/account.py b/certbot/account.py index 1928b90d8..389f96791 100644 --- a/certbot/account.py +++ b/certbot/account.py @@ -74,7 +74,8 @@ class Account(object): # pylint: disable=too-few-public-methods self.meta.creation_dt), self.meta.creation_host, self.id[:4]) def __repr__(self): - return "<{0}({1})>".format(self.__class__.__name__, self.id) + return "<{0}({1}, {2}, {3})>".format( + self.__class__.__name__, self.regr, self.id, self.meta) def __eq__(self, other): return (isinstance(other, self.__class__) and diff --git a/certbot/tests/account_test.py b/certbot/tests/account_test.py index 11d14132d..5950dcda9 100644 --- a/certbot/tests/account_test.py +++ b/certbot/tests/account_test.py @@ -33,6 +33,7 @@ class AccountTest(unittest.TestCase): creation_dt=datetime.datetime( 2015, 7, 4, 14, 4, 10, tzinfo=pytz.UTC)) self.acc = Account(self.regr, KEY, self.meta) + self.regr.__repr__ = mock.MagicMock(return_value="i_am_a_regr") with mock.patch("certbot.account.socket") as mock_socket: mock_socket.getfqdn.return_value = "test.certbot.org" @@ -54,10 +55,8 @@ class AccountTest(unittest.TestCase): self.acc.slug, "test.certbot.org@2015-07-04T14:04:10Z (bca5)") def test_repr(self): - self.assertEqual( - repr(self.acc), - "") - + self.assertTrue(repr(self.acc).startswith( + "