summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
Commit message (Collapse)AuthorAgeFilesLines
* SF patch #806246: use basestring where possibleRaymond Hettinger2003-09-171-1/+1
| | | | (Contributed by George Yoshida.)
* SF 798269: bug fix for doctest (sf bug id: 798254Raymond Hettinger2003-09-021-2/+3
| | | | | | | | | | | (Contributed by Alexander Belopolsky.) Doctest would crash when encountering unbound methods: class A: def f(self): pass class C(A): g = A.f
* Doctest now examines all docstrings by default. Previously, it wouldRaymond Hettinger2003-07-161-19/+28
| | | | | | | | | | | | skip over functions with private names (as indicated by the underscore naming convention). The old default created too much of a risk that user tests were being skipped inadvertently. Note, this change could break code in the unlikely case that someone had intentionally put failing tests in the docstrings of private functions. The breakage is easily fixable by specifying the old behavior when calling testmod() or Tester(). The more likely case is that the silent failure was unintended and that the user needed to be informed so the test could be fixed.
* Expose the 'master' instance mentioned in the docs.Raymond Hettinger2003-07-111-0/+1
|
* Some nifty doctest extensions from Jim Fulton, currently used in Zope3.Tim Peters2003-06-291-0/+268
| | | | | | | | | I won't have time to write real docs, but spent a lot of time adding comments to his code and fleshing out the exported functions' docstrings. There's probably opportunity to consolidate how docstrings get extracted too, and the new code for that is probably better than the old code for that (which strained mightily to recover from 2.2's new class/type gimmicks).
* Missed a spot where the new optional optionflags argument needed to getTim Peters2003-06-291-1/+1
| | | | passed on.
* A hack to ease compatibility with pre-2.3 Pythons: by default, doctestTim Peters2003-06-271-17/+58
| | | | | | | | | | | | | | now accepts "True" when a test expects "1", and similarly for "False" versus "0". This is un-doctest-like, but on balance makes it much more pleasant to write doctests that pass under 2.2 and 2.3. I expect it to go away again, when 2.2 is forgotten. In the meantime, there's a new doctest module constant that can be passed to a new optional argument, if you want to turn this behavior off. Note that this substitution is very simple-minded: the expected and actual outputs have to consist of single tokens. No attempt is made, e.g., to accept [True, False] when a test expects [1, 0]. This is a simple hack for simple tests, and I intend to keep it that way.
* Patch #486438: Make module argument to testmod optional.Martin v. Löwis2002-11-221-4/+12
|
* SF 563203. Replaced 'has_key()' with 'in'.Raymond Hettinger2002-06-011-2/+2
|
* Add the 'bool' type and its values 'False' and 'True', as described inGuido van Rossum2002-04-031-7/+7
| | | | | | | | | | | | | PEP 285. Everything described in the PEP is here, and there is even some documentation. I had to fix 12 unit tests; all but one of these were printing Boolean outcomes that changed from 0/1 to False/True. (The exception is test_unicode.py, which did a type(x) == type(y) style comparison. I could've fixed that with a single line using issubtype(x, type(y)), but instead chose to be explicit about those places where a bool is expected. Still to do: perhaps more documentation; change standard library modules to return False/True from predicates.
* Change raw "except:" constructs to pass on KeyboardInterrupt.Tim Peters2002-03-201-0/+4
| | | | | Bugfix candidate? Don't know -- never bothered me, but it's minor either way.
* SF bug [#473864] doctest expects spurios space.Tim Peters2001-10-231-0/+6
| | | | | | Repair unlikely surprise due to magical softspace attr and the use of print with a trailing comma in doctest examples. Bugfix candidate.
* SF bug [#467336] doctest failures w/ new-style classes.Tim Peters2001-10-031-6/+49
| | | | | | | | | | Taught doctest about static methods, class methods, and property docstrings in new-style classes. As for inspect.py/pydoc.py before it, the new stuff needed didn't really fit into the old architecture (but was less of a strain to force-fit here). New-style class docstrings still aren't found, but that's the subject of a different bug and I want to fix that right instead of hacking around it in doctest.
* SF patch [#466616] Exclude imported items from doctest.Tim Peters2001-10-021-7/+13
| | | | | Another installment; the new functionality wasn't actually enabled in normal use, only in the strained use checked by the test case.
* SF patch [#466616] Exclude imported items from doctest,Tim Peters2001-10-021-51/+70
| | | | | | | from Tim Hochberg. Also mucho fiddling to change the way doctest determines whether a thing is a function, module or class. Under 2.2, this really requires the functions in inspect.py (e.g., types.ClassType is close to meaningless now, if not outright misleading).
* Remove the horrid generators hack from doctest.py. This relies on aTim Peters2001-08-181-75/+37
| | | | | | | | | | | | | | | | | somewhat less horrid hack <wink>: if a module does from __future__ import X then the module dict D is left in a state such that (viewing X as a string) D[X] is getattr(__future__, X) So by examining D for all the names of future features, and making that test for each, we can make a darned good guess as to which future-features were imported by the module. The appropriate flags are then sucked out of the __future__ module, and passed on to compile()'s new optional arguments (PEP 264). Also gave doctest a meaningful __all__, removed the history of changes (CVS serves that purpose now), and removed the __version__ vrbl (similarly; before CVS, it was a reasonable clue, but not anymore).
* Document doctest's generator-future hack.Tim Peters2001-07-161-0/+7
|
* Ugly. A pile of new xxxFlags() functions, to communicate to the parserTim Peters2001-07-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | that 'yield' is a keyword. This doesn't help test_generators at all! I don't know why not. These things do work now (and didn't before this patch): 1. "from __future__ import generators" now works in a native shell. 2. Similarly "python -i xxx.py" now has generators enabled in the shell if xxx.py had them enabled. 3. This program (which was my doctest proxy) works fine: from __future__ import generators source = """\ def f(): yield 1 """ exec compile(source, "", "single") in globals() print type(f())
* Changed some comments. Removed the caution about clearing globs, sinceTim Peters2001-06-241-3/+3
| | | | clearing a shallow copy _run_examples() makes itself can't hurt anything.
* Clear the copy of the globs dict after running examples. This helps toTim Peters2001-06-241-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | break cycles, which are a special problem when running generator tests that provoke exceptions by invoking the .next() method of a named generator-iterator: then the iterator is named in globs, and the iterator's frame gets a tracekback object pointing back to globs, and gc doesn't chase these types so the cycle leaks. Also changed _run_examples() to make a copy of globs itself, so its callers (direct and indirect) don't have to (and changed the callers to stop making their own copies); *that* much is a change I've been meaning to make for a long time (it's more robust the new way). Here's a way to provoke the symptom without doctest; it leaks at a prodigious rate; if the last two "source" lines are replaced with g().next() the iterator isn't named and then there's no leak: source = """\ def g(): yield 1/0 k = g() k.next() """ code = compile(source, "<source>", "exec") def f(globs): try: exec code in globs except ZeroDivisionError: pass while 1: f(globals().copy()) After this change, running test_generators in an infinite loop still leaks, but reduced from a flood to a trickle.
* doctest systematically leaked memory when handling an exception in anTim Peters2001-06-241-1/+1
| | | | | example (an obvious trackback cycle). Repaired. Bugfix candidate.
* doctest doesn't handle intentional SyntaxError exceptions gracefully,Tim Peters2001-06-241-1/+1
| | | | | because it picks up the first line of traceback.format_exception_only() instead of the last line. Pick up the last line instead!
* Changed doctest to run tests in alphabetic order of name.Tim Peters2001-03-211-2/+12
| | | | | | This makes verbose-mode output easier to dig thru, and removes an accidental dependence on the order of dict.items() (made visible by recent changes to dictobject.c).
* Make doctest's self-test succeed after the previous change.Guido van Rossum2001-03-181-0/+2
|
* Print a bunch of asterisks before the failure summary, to separate itGuido van Rossum2001-03-181-0/+1
| | | | from the last failure report.
* Miranda newlines: if anything at all was written to stdout, supply aTim Peters2001-02-141-1/+7
| | | | | | | newline at the end if there isn't one already. Expected output has no way to indicate that a trailing newline was not expected, and in the interpreter shell *Python* supplies the trailing newline before printing the next prompt.
* Change doctest exception example to one whose detail hasn't changed since 1.5.2.Tim Peters2001-02-141-4/+4
|
* Teach doctest about newer "(most recent call last)" traceback spelling.Tim Peters2001-02-131-3/+4
|
* Bump __version__ tuple.Tim Peters2001-02-101-1/+1
|
* String method conversion.Eric S. Raymond2001-02-091-16/+11
|
* more __all__ updatesSkip Montanaro2001-01-201-0/+2
|
* doctest-- The Little Module That Could --finally makes it to the Big Show ↵Tim Peters2001-01-161-0/+1101
<wink>.