summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
Commit message (Collapse)AuthorAgeFilesLines
* 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>.