Also deprecated the old Tester class, which is no longer used by anything
except internal tests.
This commit is contained in:
parent
bafb1fed51
commit
3ddd60a83b
|
@ -377,7 +377,6 @@ def is_private(prefix, base):
|
|||
Return true iff base begins with an (at least one) underscore, but
|
||||
does not both begin and end with (at least) two underscores.
|
||||
|
||||
>>> import warnings
|
||||
>>> warnings.filterwarnings("ignore", "is_private", DeprecationWarning,
|
||||
... "doctest", 0)
|
||||
>>> is_private("a.b", "my_func")
|
||||
|
@ -397,7 +396,7 @@ def is_private(prefix, base):
|
|||
"""
|
||||
warnings.warn("is_private is deprecated; it wasn't useful; "
|
||||
"examine DocTestFinder.find() lists instead",
|
||||
DeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
return base[:1] == "_" and not base[:2] == "__" == base[-2:]
|
||||
|
||||
def _extract_future_flags(globs):
|
||||
|
@ -1866,6 +1865,10 @@ def run_docstring_examples(f, globs, verbose=False, name="NoName",
|
|||
class Tester:
|
||||
def __init__(self, mod=None, globs=None, verbose=None,
|
||||
isprivate=None, optionflags=0):
|
||||
|
||||
warnings.warn("class Tester is deprecated; "
|
||||
"use class doctest.DocTestRunner instead",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
if mod is None and globs is None:
|
||||
raise TypeError("Tester.__init__: must specify mod or globs")
|
||||
if mod is not None and not _ismodule(mod):
|
||||
|
@ -2403,6 +2406,8 @@ __test__ = {"_TestClass": _TestClass,
|
|||
# }
|
||||
|
||||
def test1(): r"""
|
||||
>>> warnings.filterwarnings("ignore", "class Tester", DeprecationWarning,
|
||||
... "doctest", 0)
|
||||
>>> from doctest import Tester
|
||||
>>> t = Tester(globs={'x': 42}, verbose=0)
|
||||
>>> t.runstring(r'''
|
||||
|
@ -2437,6 +2442,8 @@ Got: 84
|
|||
"""
|
||||
|
||||
def test2(): r"""
|
||||
>>> warnings.filterwarnings("ignore", "class Tester",
|
||||
... DeprecationWarning, "doctest", 0)
|
||||
>>> t = Tester(globs={}, verbose=1)
|
||||
>>> test = r'''
|
||||
... # just an example
|
||||
|
@ -2456,6 +2463,8 @@ def test2(): r"""
|
|||
(0, 2)
|
||||
"""
|
||||
def test3(): r"""
|
||||
>>> warnings.filterwarnings("ignore", "class Tester",
|
||||
... DeprecationWarning, "doctest", 0)
|
||||
>>> t = Tester(globs={}, verbose=0)
|
||||
>>> def _f():
|
||||
... '''Trivial docstring example.
|
||||
|
@ -2490,6 +2499,8 @@ def test4(): """
|
|||
|
||||
Tests that objects outside m1 are excluded:
|
||||
|
||||
>>> warnings.filterwarnings("ignore", "class Tester",
|
||||
... DeprecationWarning, "doctest", 0)
|
||||
>>> t = Tester(globs={}, verbose=0)
|
||||
>>> t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped
|
||||
(0, 4)
|
||||
|
|
25
Misc/NEWS
25
Misc/NEWS
|
@ -12,11 +12,11 @@ What's New in Python 2.4 alpha 3?
|
|||
Core and builtins
|
||||
-----------------
|
||||
|
||||
Subclasses of string can no longer be interned. The semantics of
|
||||
interning were not clear here -- a subclass could be mutable, for
|
||||
example -- and had bugs. Explicitly interning a subclass of string
|
||||
via intern() will raise a TypeError. Internal operations that attempt
|
||||
to intern a string subclass will have no effect.
|
||||
- Subclasses of string can no longer be interned. The semantics of
|
||||
interning were not clear here -- a subclass could be mutable, for
|
||||
example -- and had bugs. Explicitly interning a subclass of string
|
||||
via intern() will raise a TypeError. Internal operations that attempt
|
||||
to intern a string subclass will have no effect.
|
||||
|
||||
Extension modules
|
||||
-----------------
|
||||
|
@ -24,6 +24,21 @@ Extension modules
|
|||
Library
|
||||
-------
|
||||
|
||||
- doctest refactoring continued. See the docs for details. As part of
|
||||
this effort, some old and little- (never?) used features are now
|
||||
deprecated: the Tester class, the module is_private() function, and the
|
||||
isprivate argument to testmod(). The Tester class supplied a feeble
|
||||
"by hand" way to combine multiple doctests, if you knew exactly what
|
||||
you were doing. The newer doctest features for unittest integration
|
||||
already did a better job of that, are stronger now than ever, and the
|
||||
new DocTestRunner class is a saner foundation if you want to do it by
|
||||
hand. The "private name" filtering gimmick was a mistake from the
|
||||
start, and testmod() changed long ago to ignore it by default. If
|
||||
you want to filter out tests, the new DocTestFinder class can be used
|
||||
to return a list of all doctests, and you can filter that list by
|
||||
any computable criteria before passing it to a DocTestRunner instance.
|
||||
|
||||
|
||||
Tools/Demos
|
||||
-----------
|
||||
|
||||
|
|
Loading…
Reference in New Issue