summaryrefslogtreecommitdiff
path: root/Mailman/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Mailman/tests')
-rw-r--r--[-rwxr-xr-x]Mailman/tests/bounces/__init__.py0
-rw-r--r--Mailman/tests/test_documentation.py42
2 files changed, 31 insertions, 11 deletions
diff --git a/Mailman/tests/bounces/__init__.py b/Mailman/tests/bounces/__init__.py
index e69de29bb..e69de29bb 100755..100644
--- a/Mailman/tests/bounces/__init__.py
+++ b/Mailman/tests/bounces/__init__.py
diff --git a/Mailman/tests/test_documentation.py b/Mailman/tests/test_documentation.py
index 390ba6a66..9faf1d588 100644
--- a/Mailman/tests/test_documentation.py
+++ b/Mailman/tests/test_documentation.py
@@ -31,12 +31,25 @@ from Mailman.app.styles import style_manager
from Mailman.configuration import config
+DOT = '.'
COMMASPACE = ', '
def specialized_message_from_string(text):
- return message_from_string(text, Message)
+ """Parse text into a message object.
+
+ This is specialized in the sense that an instance of Mailman's own Message
+ object is returned, and this message object has an attribute
+ `original_size` which is the pre-calculated size in bytes of the message's
+ text representation.
+ """
+ # This mimic what Switchboard.dequeue() does when parsing a message from
+ # text into a Message instance.
+ original_size = len(text)
+ message = message_from_string(text, Message)
+ message.original_size = original_size
+ return message
def setup(testobj):
@@ -66,7 +79,12 @@ def cleaning_teardown(testobj):
def test_suite():
suite = unittest.TestSuite()
- docsdir = os.path.join(os.path.dirname(Mailman.__file__), 'docs')
+ topdir = os.path.dirname(Mailman.__file__)
+ packages = []
+ for dirpath, dirnames, filenames in os.walk(topdir):
+ if 'docs' in dirnames:
+ docsdir = os.path.join(dirpath, 'docs')[len(topdir)+1:]
+ packages.append(docsdir)
# Under higher verbosity settings, report all doctest errors, not just the
# first one.
flags = (doctest.ELLIPSIS |
@@ -74,13 +92,15 @@ def test_suite():
doctest.REPORT_NDIFF)
if config.opts.verbosity <= 2:
flags |= doctest.REPORT_ONLY_FIRST_FAILURE
- for filename in os.listdir(docsdir):
- if os.path.splitext(filename)[1] == '.txt':
- test = doctest.DocFileSuite(
- 'docs/' + filename,
- package=Mailman,
- optionflags=flags,
- setUp=setup,
- tearDown=cleaning_teardown)
- suite.addTest(test)
+ # Add all the doctests in all subpackages.
+ for docsdir in packages:
+ for filename in os.listdir(os.path.join('Mailman', docsdir)):
+ if os.path.splitext(filename)[1] == '.txt':
+ test = doctest.DocFileSuite(
+ os.path.join(docsdir, filename),
+ package='Mailman',
+ optionflags=flags,
+ setUp=setup,
+ tearDown=cleaning_teardown)
+ suite.addTest(test)
return suite