Barry Warsaw pushed to branch coverage at mailman / Mailman Core
Commits: f4768b73 by Barry Warsaw at 2017-07-27T00:19:34-04:00 Cover interfaces 100% - - - - - 5 changed files: - src/mailman/app/tests/test_lifecycle.py - src/mailman/handlers/tests/test_mimedel.py - src/mailman/interfaces/pipeline.py - src/mailman/interfaces/subscriptions.py - src/mailman/model/tests/test_subscriptions.py Changes: ===================================== src/mailman/app/tests/test_lifecycle.py ===================================== --- a/src/mailman/app/tests/test_lifecycle.py +++ b/src/mailman/app/tests/test_lifecycle.py @@ -38,8 +38,9 @@ class TestLifecycle(unittest.TestCase): def test_posting_address_validation(self): # Creating a mailing list with a bogus address raises an exception. - self.assertRaises(InvalidEmailAddressError, - create_list, 'bogus address') + with self.assertRaises(InvalidEmailAddressError) as cm: + create_list('bogus address') + self.assertEqual(str(cm.exception), 'bogus address') def test_listname_validation(self): # Creating a mailing list with invalid characters in the listname ===================================== src/mailman/handlers/tests/test_mimedel.py ===================================== --- a/src/mailman/handlers/tests/test_mimedel.py +++ b/src/mailman/handlers/tests/test_mimedel.py @@ -99,7 +99,7 @@ Message-ID: <ant> self._mlist.filter_action = FilterAction.discard with self.assertRaises(DiscardMessage) as cm: mime_delete.dispose(self._mlist, self._msg, {}, 'discarding') - self.assertEqual(cm.exception.message, 'discarding') + self.assertEqual(str(cm.exception), 'discarding') # There should be no messages in the 'bad' queue. get_queue_messages('bad', expected_count=0) @@ -107,7 +107,7 @@ Message-ID: <ant> self._mlist.filter_action = FilterAction.reject with self.assertRaises(RejectMessage) as cm: mime_delete.dispose(self._mlist, self._msg, {}, 'rejecting') - self.assertEqual(cm.exception.message, 'rejecting') + self.assertEqual(str(cm.exception), 'rejecting') # There should be no messages in the 'bad' queue. get_queue_messages('bad', expected_count=0) ===================================== src/mailman/interfaces/pipeline.py ===================================== --- a/src/mailman/interfaces/pipeline.py +++ b/src/mailman/interfaces/pipeline.py @@ -21,11 +21,6 @@ from public import public from zope.interface import Attribute, Interface -# For i18n extraction. -def _(s): - return s - - # These are thrown but they aren't exceptions so don't inherit from # mailman.interfaces.errors.MailmanError. Python requires that they inherit # from BaseException. ===================================== src/mailman/interfaces/subscriptions.py ===================================== --- a/src/mailman/interfaces/subscriptions.py +++ b/src/mailman/interfaces/subscriptions.py @@ -26,18 +26,6 @@ from zope.interface import Interface @public -class MissingUserError(MailmanError): - """A an invalid user id was given.""" - - def __init__(self, user_id): - super().__init__() - self.user_id = user_id - - def __str__(self): - return self.user_id - - -@public class SubscriptionPendingError(MailmanError): def __init__(self, mlist, email): super().__init__() ===================================== src/mailman/model/tests/test_subscriptions.py ===================================== --- a/src/mailman/model/tests/test_subscriptions.py +++ b/src/mailman/model/tests/test_subscriptions.py @@ -237,8 +237,11 @@ class TestSubscriptionService(unittest.TestCase): def test_leave_no_such_list(self): # Trying to leave a nonexistent list raises an exception. - self.assertRaises(NoSuchListError, self._service.leave, - 'bogus.example.com', 'a...@example.com') + with self.assertRaises(NoSuchListError) as cm: + self._service.leave('bogus.example.com', 'a...@example.com') + self.assertEqual( + str(cm.exception), + 'No such mailing list: bogus.example.com') def test_unsubscribe_members_no_such_list(self): # Raises an exception if an invalid list_id is passed View it on GitLab: https://gitlab.com/mailman/mailman/commit/f4768b735f3800de69afd9b6a6b1043a2cbd003b --- View it on GitLab: https://gitlab.com/mailman/mailman/commit/f4768b735f3800de69afd9b6a6b1043a2cbd003b You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org