26
26
__metaclass__ = type
37
33
from inspect import isfunction, ismethod
41
35
from mailman.app.lifecycle import create_list
42
36
from mailman.config import config
43
from mailman.testing.helpers import (
44
call_api, chdir, specialized_message_from_string)
37
from mailman.testing.helpers import call_api, specialized_message_from_string
45
38
from mailman.testing.layers import SMTPLayer
183
176
cleanup[0](*cleanup[1:])
188
"""Create test suites for all .rst documentation tests.
190
.txt files are also tested, but .rst is highly preferred.
192
suite = unittest.TestSuite()
193
topdir = os.path.dirname(mailman.__file__)
195
for dirpath, dirnames, filenames in os.walk(topdir):
196
if 'docs' in dirnames:
197
docsdir = os.path.join(dirpath, 'docs')[len(topdir)+1:]
198
packages.append(docsdir)
199
# Under higher verbosity settings, report all doctest errors, not just the
201
flags = (doctest.ELLIPSIS |
202
doctest.NORMALIZE_WHITESPACE |
203
doctest.REPORT_NDIFF)
204
# Add all the doctests in all subpackages.
207
for docsdir in packages:
208
# Look to see if the package defines a test layer, otherwise use
210
package_path = 'mailman.' + DOT.join(docsdir.split(os.sep))
212
__import__(package_path)
216
layer = getattr(sys.modules[package_path], 'layer', SMTPLayer)
217
for filename in os.listdir(docsdir):
218
base, extension = os.path.splitext(filename)
219
if os.path.splitext(filename)[1] in ('.txt', '.rst'):
220
module_path = package_path + '.' + base
221
doctest_files[module_path] = (
222
os.path.join(docsdir, filename), layer)
223
for module_path in sorted(doctest_files):
224
path, layer = doctest_files[module_path]
225
test = doctest.DocFileSuite(