summaryrefslogtreecommitdiff
path: root/Mailman/testing
diff options
context:
space:
mode:
authorBarry Warsaw2007-06-19 18:42:27 -0400
committerBarry Warsaw2007-06-19 18:42:27 -0400
commit3a86b40fe4e3b28c2d9f4e3bbd2cc0eeefe31453 (patch)
treee7bb34c284974cb38fce21cc5ad0d28fc50a3a98 /Mailman/testing
parent0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d (diff)
downloadmailman-3a86b40fe4e3b28c2d9f4e3bbd2cc0eeefe31453.tar.gz
mailman-3a86b40fe4e3b28c2d9f4e3bbd2cc0eeefe31453.tar.zst
mailman-3a86b40fe4e3b28c2d9f4e3bbd2cc0eeefe31453.zip
Convert the Cleanse handler tests to doctest style.
Diffstat (limited to 'Mailman/testing')
-rw-r--r--Mailman/testing/test_cleanse.py32
-rw-r--r--Mailman/testing/test_handlers.py65
2 files changed, 32 insertions, 65 deletions
diff --git a/Mailman/testing/test_cleanse.py b/Mailman/testing/test_cleanse.py
new file mode 100644
index 000000000..97ad9c46c
--- /dev/null
+++ b/Mailman/testing/test_cleanse.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2007 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+"""Doctest harness for the Cleanse handler."""
+
+import doctest
+import unittest
+
+options = (doctest.ELLIPSIS
+ | doctest.NORMALIZE_WHITESPACE
+ | doctest.REPORT_NDIFF)
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(doctest.DocFileSuite('../docs/cleanse.txt',
+ optionflags=options))
+ return suite
diff --git a/Mailman/testing/test_handlers.py b/Mailman/testing/test_handlers.py
index bbc7f5ba8..e6a846412 100644
--- a/Mailman/testing/test_handlers.py
+++ b/Mailman/testing/test_handlers.py
@@ -39,7 +39,6 @@ from Mailman.testing.base import TestBase
from Mailman.Handlers import Acknowledge
from Mailman.Handlers import AfterDelivery
from Mailman.Handlers import Approve
-from Mailman.Handlers import Cleanse
from Mailman.Handlers import CookHeaders
from Mailman.Handlers import FileRecips
from Mailman.Handlers import Hold
@@ -137,69 +136,6 @@ X-BeenThere: %s
-class TestCleanse(TestBase):
- def setUp(self):
- TestBase.setUp(self)
-
- def test_simple_cleanse(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-Approved: yes
-Urgent: indeed
-Reply-To: bperson@example.com
-Sender: asystem@example.com
-Return-Receipt-To: another@example.com
-Disposition-Notification-To: athird@example.com
-X-Confirm-Reading-To: afourth@example.com
-X-PMRQC: afifth@example.com
-Subject: a message to you
-
-""", Message.Message)
- Cleanse.process(self._mlist, msg, {})
- eq(msg['approved'], None)
- eq(msg['urgent'], None)
- eq(msg['return-receipt-to'], None)
- eq(msg['disposition-notification-to'], None)
- eq(msg['x-confirm-reading-to'], None)
- eq(msg['x-pmrqc'], None)
- eq(msg['from'], 'aperson@example.org')
- eq(msg['reply-to'], 'bperson@example.com')
- eq(msg['sender'], 'asystem@example.com')
- eq(msg['subject'], 'a message to you')
-
- def test_anon_cleanse(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-Approved: yes
-Urgent: indeed
-Reply-To: bperson@example.com
-Sender: asystem@example.com
-Return-Receipt-To: another@example.com
-Disposition-Notification-To: athird@example.com
-X-Confirm-Reading-To: afourth@example.com
-X-PMRQC: afifth@example.com
-Subject: a message to you
-
-""", Message.Message)
- self._mlist.anonymous_list = 1
- Cleanse.process(self._mlist, msg, {})
- eq(msg['approved'], None)
- eq(msg['urgent'], None)
- eq(msg['return-receipt-to'], None)
- eq(msg['disposition-notification-to'], None)
- eq(msg['x-confirm-reading-to'], None)
- eq(msg['x-pmrqc'], None)
- eq(len(msg.get_all('from')), 1)
- eq(len(msg.get_all('reply-to')), 1)
- eq(msg['from'], '_xtest@example.com')
- eq(msg['reply-to'], '_xtest@example.com')
- eq(msg['sender'], None)
- eq(msg['subject'], 'a message to you')
-
-
-
class TestCookHeaders(TestBase):
def test_transform_noack_to_xack(self):
eq = self.assertEqual
@@ -1463,7 +1399,6 @@ Mailman rocks!
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestApprove))
- suite.addTest(unittest.makeSuite(TestCleanse))
suite.addTest(unittest.makeSuite(TestCookHeaders))
suite.addTest(unittest.makeSuite(TestFileRecips))
suite.addTest(unittest.makeSuite(TestHold))