]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merge rev 50882 from the trunk.
authorTim Peters <tim.peters@gmail.com>
Thu, 27 Jul 2006 23:56:12 +0000 (23:56 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 27 Jul 2006 23:56:12 +0000 (23:56 +0000)
Bug #1529297:  The rewrite of doctest for Python 2.4 unintentionally
lost that tests are sorted by name before being run.  ``DocTestFinder``
has been changed to sort the list of tests it returns.

Lib/doctest.py
Lib/test/test_doctest.py
Misc/NEWS

index a3953417c0e9e0df8721c02d456d2dd95fad51f8..e4348b5258fc469ecf6d0d9dcbeefb33a57d0f49 100644 (file)
@@ -848,6 +848,11 @@ class DocTestFinder:
         # Recursively expore `obj`, extracting DocTests.
         tests = []
         self._find(tests, obj, name, module, source_lines, globs, {})
+        # Sort the tests by alpha order of names, for consistency in
+        # verbose-mode output.  This was a feature of doctest in Pythons
+        # <= 2.3 that got lost by accident in 2.4.  It was repaired in
+        # 2.4.4 and 2.5.
+        tests.sort()
         return tests
 
     def _filter(self, obj, prefix, base):
index 36ffec906f9987b019a193e26fddd9dff89056ba..559b575d275aabfa4952f0fbc85ebfb15e0d4afa 100644 (file)
@@ -419,7 +419,6 @@ methods, classmethods, staticmethods, properties, and nested classes.
 
     >>> finder = doctest.DocTestFinder()
     >>> tests = finder.find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass
@@ -435,7 +434,6 @@ methods, classmethods, staticmethods, properties, and nested classes.
 New-style classes are also supported:
 
     >>> tests = finder.find(SampleNewStyleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      1  SampleNewStyleClass
@@ -475,7 +473,6 @@ functions, classes, and the `__test__` dictionary, if it exists:
     >>> # ignoring the objects since they weren't defined in m.
     >>> import test.test_doctest
     >>> tests = finder.find(m, module=test.test_doctest)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      1  some_module
@@ -499,7 +496,6 @@ will only be generated for it once:
 
     >>> from test import doctest_aliases
     >>> tests = excl_empty_finder.find(doctest_aliases)
-    >>> tests.sort()
     >>> print len(tests)
     2
     >>> print tests[0].name
@@ -521,7 +517,6 @@ deprecated isprivate gimmick.
     >>> def namefilter(prefix, base):
     ...     return base.startswith('a_')
     >>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass
@@ -538,7 +533,6 @@ displays.
 
     >>> tests = doctest.DocTestFinder(_namefilter=namefilter,
     ...                                exclude_empty=False).find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass
@@ -582,7 +576,6 @@ DocTestFinder can be told not to look for tests in contained objects
 using the `recurse` flag:
 
     >>> tests = doctest.DocTestFinder(recurse=False).find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass
index 003581255acb578e56741263d714a15c5234f74c..48c9f16c3b7b02c3dae8f24f565c679c9e937371 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,9 +31,9 @@ Core and builtins
 Extension Modules
 -----------------
 
-- Bug #1471938: Fix curses module build problem on Solaris 8; patch by 
+- Bug #1471938: Fix curses module build problem on Solaris 8; patch by
   Paul Eggert.
+
 - Bug #1512695: cPickle.loads could crash if it was interrupted with
   a KeyboardInterrupt.
 
@@ -64,6 +64,12 @@ Extension Modules
 Library
 -------
 
+- Bug #1529297:  The rewrite of doctest for Python 2.4 unintentionally
+  lost that tests are sorted by name before being run.  This rarely
+  matters for well-written tests, but can create baffling symptoms if
+  side effects from one test to the next affect outcomes.  ``DocTestFinder``
+  has been changed to sort the list of tests it returns.
+
 - The email package has improved RFC 2231 support, specifically for
   recognizing the difference between encoded (name*0*=<blah>) and non-encoded
   (name*0=<blah>) parameter continuations.  This may change the types of