From 2b5060ef4d43a279d084e0fd7e3f98a38e154259 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 12 Mar 2008 21:52:43 -0400 Subject: Add some randomization to the way tests are run. This isn't complete (see the help for bin/testall --randomize for details), but it still better than nothing. --- mailman/tests/test_documentation.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'mailman/tests/test_documentation.py') diff --git a/mailman/tests/test_documentation.py b/mailman/tests/test_documentation.py index 69acd9d7b..e805b10fa 100644 --- a/mailman/tests/test_documentation.py +++ b/mailman/tests/test_documentation.py @@ -18,6 +18,7 @@ """Harness for testing Mailman's documentation.""" import os +import random import doctest import unittest @@ -94,17 +95,27 @@ def test_suite(): flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF) - if config.verbosity <= 2: + if config.tests.verbosity <= 2: flags |= doctest.REPORT_ONLY_FIRST_FAILURE # Add all the doctests in all subpackages. + doctest_files = {} 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) + doctest_files[filename] = os.path.join(docsdir, filename) + # Sort or randomize the tests. + if config.tests.randomize: + files = doctest_files.keys() + random.shuffle(files) + else: + files = sorted(doctest_files) + for filename in files: + path = doctest_files[filename] + test = doctest.DocFileSuite( + path, + package='mailman', + optionflags=flags, + setUp=setup, + tearDown=cleaning_teardown) + suite.addTest(test) return suite -- cgit v1.2.3-70-g09d2