mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Reluctantly, rehabilitate doctest.master.
This commit is contained in:
parent
9661f9ab4f
commit
82076ef194
2 changed files with 41 additions and 16 deletions
|
@ -1531,6 +1531,20 @@ class DocTestRunner:
|
||||||
print "Test passed."
|
print "Test passed."
|
||||||
return totalf, totalt
|
return totalf, totalt
|
||||||
|
|
||||||
|
#/////////////////////////////////////////////////////////////////
|
||||||
|
# Backward compatibility cruft to maintain doctest.master.
|
||||||
|
#/////////////////////////////////////////////////////////////////
|
||||||
|
def merge(self, other):
|
||||||
|
d = self._name2ft
|
||||||
|
for name, (f, t) in other._name2ft.items():
|
||||||
|
if name in d:
|
||||||
|
print "*** DocTestRunner.merge: '" + name + "' in both" \
|
||||||
|
" testers; summing outcomes."
|
||||||
|
f2, t2 = d[name]
|
||||||
|
f = f + f2
|
||||||
|
t = t + t2
|
||||||
|
d[name] = f, t
|
||||||
|
|
||||||
class OutputChecker:
|
class OutputChecker:
|
||||||
"""
|
"""
|
||||||
A class used to check the whether the actual output from a doctest
|
A class used to check the whether the actual output from a doctest
|
||||||
|
@ -1810,6 +1824,10 @@ class DebugRunner(DocTestRunner):
|
||||||
######################################################################
|
######################################################################
|
||||||
# These should be backwards compatible.
|
# These should be backwards compatible.
|
||||||
|
|
||||||
|
# For backward compatibility, a global instance of a DocTestRunner
|
||||||
|
# class, updated by testmod.
|
||||||
|
master = None
|
||||||
|
|
||||||
def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
|
def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
|
||||||
report=True, optionflags=0, extraglobs=None,
|
report=True, optionflags=0, extraglobs=None,
|
||||||
raise_on_error=False):
|
raise_on_error=False):
|
||||||
|
@ -1883,6 +1901,8 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
|
||||||
displaying a summary. Invoke doctest.master.summarize(verbose)
|
displaying a summary. Invoke doctest.master.summarize(verbose)
|
||||||
when you're done fiddling.
|
when you're done fiddling.
|
||||||
"""
|
"""
|
||||||
|
global master
|
||||||
|
|
||||||
if isprivate is not None:
|
if isprivate is not None:
|
||||||
warnings.warn("the isprivate argument is deprecated; "
|
warnings.warn("the isprivate argument is deprecated; "
|
||||||
"examine DocTestFinder.find() lists instead",
|
"examine DocTestFinder.find() lists instead",
|
||||||
|
@ -1917,6 +1937,11 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
|
||||||
if report:
|
if report:
|
||||||
runner.summarize()
|
runner.summarize()
|
||||||
|
|
||||||
|
if master is None:
|
||||||
|
master = runner
|
||||||
|
else:
|
||||||
|
master.merge(runner)
|
||||||
|
|
||||||
return runner.failures, runner.tries
|
return runner.failures, runner.tries
|
||||||
|
|
||||||
def run_docstring_examples(f, globs, verbose=False, name="NoName",
|
def run_docstring_examples(f, globs, verbose=False, name="NoName",
|
||||||
|
@ -2007,15 +2032,7 @@ class Tester:
|
||||||
return self.testrunner.summarize(verbose)
|
return self.testrunner.summarize(verbose)
|
||||||
|
|
||||||
def merge(self, other):
|
def merge(self, other):
|
||||||
d = self.testrunner._name2ft
|
self.testrunner.merge(other.testrunner)
|
||||||
for name, (f, t) in other.testrunner._name2ft.items():
|
|
||||||
if name in d:
|
|
||||||
print "*** Tester.merge: '" + name + "' in both" \
|
|
||||||
" testers; summing outcomes."
|
|
||||||
f2, t2 = d[name]
|
|
||||||
f = f + f2
|
|
||||||
t = t + t2
|
|
||||||
d[name] = f, t
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## 8. Unittest Support
|
## 8. Unittest Support
|
||||||
|
|
22
Misc/NEWS
22
Misc/NEWS
|
@ -22,9 +22,10 @@ Extension modules
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
- bdist_rpm now supports command line options --force-arch,
|
- bdist_rpm now supports command line options --force-arch,
|
||||||
{pre,post}-install, {pre,post}-uninstall, and
|
{pre,post}-install, {pre,post}-uninstall, and
|
||||||
{prep,build,install,clean,verify}-script.
|
{prep,build,install,clean,verify}-script.
|
||||||
|
|
||||||
- SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
|
- SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
|
||||||
decoding incomplete input (when the input stream is temporarily exhausted).
|
decoding incomplete input (when the input stream is temporarily exhausted).
|
||||||
``codecs.StreamReader`` now implements buffering, which enables proper
|
``codecs.StreamReader`` now implements buffering, which enables proper
|
||||||
|
@ -34,6 +35,13 @@ Library
|
||||||
``codecs.StreamReader.readlines()`` have a new argument ``keepends``.
|
``codecs.StreamReader.readlines()`` have a new argument ``keepends``.
|
||||||
Trailing "\n"s will be stripped from the lines if ``keepends`` is false.
|
Trailing "\n"s will be stripped from the lines if ``keepends`` is false.
|
||||||
|
|
||||||
|
- ``doctest.master was`` put back in, and ``doctest.testmod()`` once again
|
||||||
|
updates it. This isn't good, because every ``testmod()`` call
|
||||||
|
contributes to bloating the "hidden" state of ``doctest.master``, but
|
||||||
|
some old code apparently relies on it. For now, all we can do is
|
||||||
|
encourage people to stitch doctests together via doctest's unittest
|
||||||
|
integration features instead. It would help if those were documented.
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -85,7 +93,7 @@ What's New in Python 2.4 alpha 3?
|
||||||
Core and builtins
|
Core and builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
- SF patch #1007189: ``from ... import ...`` statements now allow the name
|
- SF patch #1007189: ``from ... import ...`` statements now allow the name
|
||||||
list to be surrounded by parentheses.
|
list to be surrounded by parentheses.
|
||||||
|
|
||||||
- Some speedups for long arithmetic, thanks to Trevor Perrin. Gradeschool
|
- Some speedups for long arithmetic, thanks to Trevor Perrin. Gradeschool
|
||||||
|
@ -152,14 +160,14 @@ Extension modules
|
||||||
- Added CurrentByteIndex, CurrentColumnNumber, CurrentLineNumber
|
- Added CurrentByteIndex, CurrentColumnNumber, CurrentLineNumber
|
||||||
members to xml.parsers.expat.XMLParser object.
|
members to xml.parsers.expat.XMLParser object.
|
||||||
|
|
||||||
- The mpz, rotor, and xreadlines modules, all deprecated in earlier
|
- The mpz, rotor, and xreadlines modules, all deprecated in earlier
|
||||||
versions of Python, have now been removed.
|
versions of Python, have now been removed.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
- Patch #934356: if a module defines __all__, believe that rather than using
|
- Patch #934356: if a module defines __all__, believe that rather than using
|
||||||
heuristics for filtering out imported names.
|
heuristics for filtering out imported names.
|
||||||
|
|
||||||
- Patch #941486: added os.path.lexists(), which returns True for broken
|
- Patch #941486: added os.path.lexists(), which returns True for broken
|
||||||
symlinks, unlike os.path.exists().
|
symlinks, unlike os.path.exists().
|
||||||
|
@ -330,10 +338,10 @@ Core and builtins
|
||||||
|
|
||||||
- PEP-0318, Function Decorators have been added to the language. These are
|
- PEP-0318, Function Decorators have been added to the language. These are
|
||||||
implemented using the Java-style @decorator syntax, like so::
|
implemented using the Java-style @decorator syntax, like so::
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def foo(bar):
|
def foo(bar):
|
||||||
|
|
||||||
(The PEP needs to be updated to reflect the current state)
|
(The PEP needs to be updated to reflect the current state)
|
||||||
|
|
||||||
- When importing a module M raises an exception, Python no longer leaves M
|
- When importing a module M raises an exception, Python no longer leaves M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue