diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/app/tests/test_bounces.py | 10 | ||||
| -rw-r--r-- | src/mailman/app/tests/test_inject.py | 10 | ||||
| -rw-r--r-- | src/mailman/app/tests/test_moderation.py | 5 | ||||
| -rw-r--r-- | src/mailman/app/tests/test_notifications.py | 10 | ||||
| -rw-r--r-- | src/mailman/chains/tests/test_hold.py | 5 | ||||
| -rw-r--r-- | src/mailman/mta/tests/test_aliases.py | 13 | ||||
| -rw-r--r-- | src/mailman/mta/tests/test_delivery.py | 10 |
7 files changed, 24 insertions, 39 deletions
diff --git a/src/mailman/app/tests/test_bounces.py b/src/mailman/app/tests/test_bounces.py index 3c4c80faf..be2c5cb78 100644 --- a/src/mailman/app/tests/test_bounces.py +++ b/src/mailman/app/tests/test_bounces.py @@ -308,6 +308,9 @@ $address $optionsurl $owneraddr """, file=fp) + # Python 2.7 has assertMultiLineEqual. Let this work without bounds. + self.maxDiff = None + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def tearDown(self): config.pop('xx template dir') @@ -328,12 +331,7 @@ $owneraddr send_probe(self._member, self._msg) message = get_queue_messages('virgin')[0].msg notice = message.get_payload(0).get_payload() - try: - # Python 2.7 - eq = self.assertMultiLineEqual - except AttributeError: - eq = self.assertEqual - eq(notice, """\ + self.eq(notice, """\ blah blah blah test@example.com anne@example.com http://example.com/anne@example.com test-owner@example.com""") diff --git a/src/mailman/app/tests/test_inject.py b/src/mailman/app/tests/test_inject.py index 2815878ab..de7e4bd29 100644 --- a/src/mailman/app/tests/test_inject.py +++ b/src/mailman/app/tests/test_inject.py @@ -45,8 +45,6 @@ class TestInjectMessage(unittest.TestCase): layer = ConfigLayer def setUp(self): - # Python 2.7 has a better equality tester for message texts. - self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) self.mlist = create_list('test@example.com') self.msg = message_from_string("""\ From: anne@example.com @@ -57,8 +55,9 @@ Date: Tue, 14 Jun 2011 21:12:00 -0400 Nothing. """) - # For Python 2.7. + # Python 2.7 has assertMultiLineEqual. Let this work without bounds. self.maxDiff = None + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def test_inject_message(self): # Test basic inject_message() call. @@ -132,8 +131,6 @@ class TestInjectText(unittest.TestCase): layer = ConfigLayer def setUp(self): - # Python 2.7 has a better equality tester for message texts. - self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) self.mlist = create_list('test@example.com') self.text = b"""\ From: bart@example.com @@ -144,8 +141,9 @@ Date: Tue, 14 Jun 2011 21:12:00 -0400 Nothing. """ - # For Python 2.7. + # Python 2.7 has a better equality tester for message texts. self.maxDiff = None + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def _remove_line(self, header): return NL.join(line for line in self.text.splitlines() diff --git a/src/mailman/app/tests/test_moderation.py b/src/mailman/app/tests/test_moderation.py index 262aa4480..dea2f5918 100644 --- a/src/mailman/app/tests/test_moderation.py +++ b/src/mailman/app/tests/test_moderation.py @@ -56,10 +56,9 @@ Message-ID: <alpha> self._in = make_testable_runner(IncomingRunner, 'in') self._pipeline = make_testable_runner(PipelineRunner, 'pipeline') self._out = make_testable_runner(OutgoingRunner, 'out') - # Python 2.7 has assertMultiLineEqual + # Python 2.7 has assertMultiLineEqual. Let this work without bounds. self.maxDiff = None - self.eq = getattr(self, 'assertMultiLineEqual', - getattr(self, 'assertEqual')) + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def test_accepted_message_gets_posted(self): # A message that is accepted by the moderator should get posted to the diff --git a/src/mailman/app/tests/test_notifications.py b/src/mailman/app/tests/test_notifications.py index 392cc535d..42f482582 100644 --- a/src/mailman/app/tests/test_notifications.py +++ b/src/mailman/app/tests/test_notifications.py @@ -74,6 +74,9 @@ Welcome to the $list_name mailing list. os.makedirs(path) with open(os.path.join(path, 'welcome.txt'), 'w') as fp: print('You just joined the $list_name mailing list!', file=fp) + # Python 2.7 has assertMultiLineEqual. Let this work without bounds. + self.maxDiff = None + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def tearDown(self): config.pop('template config') @@ -91,12 +94,7 @@ Welcome to the $list_name mailing list. message = messages[0].msg self.assertEqual(str(message['subject']), 'Welcome to the "Test List" mailing list') - try: - eq = self.assertMultiLineEqual - except AttributeError: - # Python 2.6 - eq = self.assertEqual - eq(message.get_payload(), """\ + self.eq(message.get_payload(), """\ Welcome to the Test List mailing list. Posting address: test@example.com diff --git a/src/mailman/chains/tests/test_hold.py b/src/mailman/chains/tests/test_hold.py index 3c337a501..f2cd1dabf 100644 --- a/src/mailman/chains/tests/test_hold.py +++ b/src/mailman/chains/tests/test_hold.py @@ -45,10 +45,9 @@ class TestAutorespond(unittest.TestCase): def setUp(self): self._mlist = create_list('test@example.com') - # Python 2.7 has assertMultiLineEqual + # Python 2.7 has assertMultiLineEqual. Let this work without bounds. self.maxDiff = None - self.eq = getattr(self, 'assertMultiLineEqual', - getattr(self, 'assertEqual')) + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def test_max_autoresponses_per_day(self): # The last one we sent was the last one we should send today. Instead diff --git a/src/mailman/mta/tests/test_aliases.py b/src/mailman/mta/tests/test_aliases.py index bf77298e6..b1a60bc95 100644 --- a/src/mailman/mta/tests/test_aliases.py +++ b/src/mailman/mta/tests/test_aliases.py @@ -127,26 +127,23 @@ class TestPostfix(unittest.TestCase): """Test the Postfix LMTP alias generator.""" layer = ConfigLayer - # For Python 2.7's assertMultiLineEqual - maxDiff = None def setUp(self): self.utility = getUtility(IMailTransportAgentAliases) self.mlist = create_list('test@example.com') self.output = StringIO() self.postfix = LMTP() - # For Python 2.7's unittest. + # Python 2.7 has assertMultiLineEqual. Let this work without bounds. self.maxDiff = None + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def test_aliases(self): # Test the format of the Postfix alias generator. self.postfix.regenerate(self.output) - # Python 2.7 has assertMultiLineEqual but Python 2.6 does not. - eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) # Strip out the variable and unimportant bits of the output. lines = self.output.getvalue().splitlines() output = NL.join(lines[7:]) - eq(output, """\ + self.eq(output, """\ # Aliases which are visible only in the @example.com domain. test@example.com lmtp:[127.0.0.1]:9024 test-bounces@example.com lmtp:[127.0.0.1]:9024 @@ -163,13 +160,11 @@ test-unsubscribe@example.com lmtp:[127.0.0.1]:9024 # Both lists need to show up in the aliases file. LP: #874929. # Create a second list. create_list('other@example.com') - # Python 2.7 has assertMultiLineEqual but Python 2.6 does not. - eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) self.postfix.regenerate(self.output) # Strip out the variable and unimportant bits of the output. lines = self.output.getvalue().splitlines() output = NL.join(lines[7:]) - eq(output, """\ + self.eq(output, """\ # Aliases which are visible only in the @example.com domain. other@example.com lmtp:[127.0.0.1]:9024 other-bounces@example.com lmtp:[127.0.0.1]:9024 diff --git a/src/mailman/mta/tests/test_delivery.py b/src/mailman/mta/tests/test_delivery.py index 1e362d755..fbac0d121 100644 --- a/src/mailman/mta/tests/test_delivery.py +++ b/src/mailman/mta/tests/test_delivery.py @@ -95,6 +95,9 @@ options : $user_optionsurl template_dir: {0} """.format(self._template_dir)) self._mlist.footer_uri = 'mailman:///member-footer.txt' + # Python 2.7 has assertMultiLineEqual. Let this work without bounds. + self.maxDiff = None + self.eq = getattr(self, 'assertMultiLineEqual', self.assertEqual) def tearDown(self): # Free references. @@ -121,12 +124,7 @@ options : $user_optionsurl self.assertEqual(len(refused), 0) self.assertEqual(len(_deliveries), 1) _mlist, _msg, _msgdata, _recipients = _deliveries[0] - try: - eq = self.assertMultiLineEqual - except AttributeError: - # Python 2.6 - eq = self.assertEqual - eq(_msg.as_string(), """\ + self.eq(_msg.as_string(), """\ From: anne@example.org To: test@example.com Subject: test |
