From 55b97d69b0c08e66215a673f3cd92ab7d260c714 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sat, 23 Jun 2007 08:38:45 -0400 Subject: Simplify doctests by having just a single test_documentation.py module in Mailman/testing. This introspects the Mailman/docs directory and adds DocFileSuites for all .txt files found there. --- Mailman/testing/test_documentation.py | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Mailman/testing/test_documentation.py (limited to 'Mailman/testing/test_documentation.py') diff --git a/Mailman/testing/test_documentation.py b/Mailman/testing/test_documentation.py new file mode 100644 index 000000000..99c2ffbae --- /dev/null +++ b/Mailman/testing/test_documentation.py @@ -0,0 +1,68 @@ +# 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. + +"""Harness for testing Mailman's documentation.""" + +import os +import doctest +import unittest + +import Mailman +from Mailman.configuration import config +from Mailman.database import flush + + +COMMASPACE = ', ' + + + +def cleaning_teardown(testobj): + for user in config.user_manager.users: + config.user_manager.delete_user(user) + for address in config.user_manager.addresses: + config.user_manager.delete_address(address) + for mlist in config.list_manager.mailing_lists: + for member in mlist.members.members: + member.unsubscribe() + for admin in mlist.administrators.members: + admin.unsubscribe() + config.list_manager.delete(mlist) + flush() + assert not list(config.list_manager.mailing_lists), ( + 'There should be no mailing lists left: %s' % + COMMASPACE.join(sorted(config.list_manager.names))) + assert not list(config.user_manager.users), ( + 'There should be no users left!') + assert not list(config.user_manager.addresses), ( + 'There should be no addresses left!') + + + +def test_suite(): + suite = unittest.TestSuite() + docsdir = os.path.join(os.path.dirname(Mailman.__file__), 'docs') + for filename in os.listdir(docsdir): + if os.path.splitext(filename)[1] == '.txt': + test = doctest.DocFileSuite( + 'docs/' + filename, + package=Mailman, + optionflags=(doctest.ELLIPSIS + | doctest.NORMALIZE_WHITESPACE + | doctest.REPORT_NDIFF), + tearDown=cleaning_teardown) + suite.addTest(test) + return suite -- cgit v1.2.3-70-g09d2