summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Moved some test cases from doctest to test_doctest.Tim Peters2004-08-231-116/+0
|
* Misc cleanups.Tim Peters2004-08-231-28/+26
|
* debug_script(): I changed this in haste before to take out the use ofTim Peters2004-08-231-15/+22
| | | | | | | NamedTemporaryFile (which can't work for this function's purposes on Windows). Leaving temp files behind wasn't a great idea either, though, so try to clean up. At least the test suite no longer leaves any of these guys behind now.
* Start deferring to the LaTeX docs for details. I'd like to move theTim Peters2004-08-221-29/+3
| | | | | | | | | docstrings toward being a lot shorter, and telling the whole truth in the manual instead. This change is an example: the manual has detailed explanations of the option names now, so it's Bad to repeat them in the docstring (two detailed descriptions are certain to get out of synch). Just listing the names has memory-jogging benefits, though, so that's still helpful in the docstring.
* Added NDIFF_DIFF option.Tim Peters2004-08-221-6/+28
|
* Type in docstring.Tim Peters2004-08-221-1/+1
|
* _parse_example(): Simplified new code to preserve trailing spaces beforeTim Peters2004-08-221-12/+8
| | | | final newline. Anything to get rid of "l" as a variable name <0.5 wink>.
* Bugs fixed:Jim Fulton2004-08-221-24/+45
| | | | | | | | | | | | | | | - Test filenames sometimes had trailing .pyc or .pyo sufixes (when module __file__ did). - Trailing spaces spaces in expected output were dropped. New default failure format: - Separation of examples from file info makes examples easier to see - More vertical separation, improving readability - Emacs-recognized file info (also closer to Python exception format)
* _ellipsis_match(): Removed special-casing of "...\n". The semanticsTim Peters2004-08-221-4/+0
| | | | | | are non-obvious either way because the newline character "is invisible", but it's still there all the same, and it's easier to explain/predict if that reality is left alone.
* Gave _ellipsis_match() an attractive new leading underscore.Tim Peters2004-08-201-4/+4
|
* Got rid of nooutput() (was used by DocTestCase.debug())Edward Loper2004-08-191-5/+1
| | | | | | It's redundant, since no output is written anyway: DebugRunner doesn't generate any output for failures and unexpected exceptions, and since verbose=False, it won't generate any output for non-failures either.
* Updated __all__ to include every non-underscored class, function, andEdward Loper2004-08-191-2/+30
| | | | | constant defined by the module (except the test*() functions, which should be integrated into test/test_doctest.py, anyway).
* ellipsis_match(): Changed treatment of start- and end-of-string exactTim Peters2004-08-191-25/+35
| | | | matches to be symmetric. This makes the algorithm easier to understand.
* Replaced the ELLIPSIS implementation with a worst-case linear-time one.Tim Peters2004-08-191-15/+46
|
* ELLIPSIS implementation: an ellipsis couldn't match nothing if itTim Peters2004-08-191-4/+8
| | | | | | | appeared at the end of a line. Repaired that. Also noted that it's too easy to provoke this implementation into requiring exponential time, and especially when a test fails. I'll replace the implementation with an always-efficient one later.
* Fixed bug in line-number finding for examples (DocTestParser wasn'tEdward Loper2004-08-171-5/+3
| | | | | updating line numbers correctly for bare prompts & examples containing only comments).
* Doctest has new traceback gimmicks in 2.4. While trying to documentTim Peters2004-08-131-16/+26
| | | | | | them (which they are now), I had to rewrite the code to understand it. This has got to be the most DWIM part of doctest -- but in context is really necessary.
* Nit in _IS_BLANK_OR_COMMENT comment -- it doesn't matter how this isTim Peters2004-08-131-2/+2
| | | | implemented, just what it does.
* In output_difference(), replace blank lines in `want` with <BLANKLINE>Edward Loper2004-08-121-3/+3
| | | | | (rather than replacing <BLANKLINE> with blank lines in `got`). This makes it easier to see what's intended.
* - Changed output of DocTestParser.get_program() to make it easier toEdward Loper2004-08-121-15/+29
| | | | | | | | visually distinguish the expected output from the comments (use "##" to mark expected outputs, and "#" to mark comments). - If the string given to DocTestParser.get_program() is indented, then strip its indentation. (In particular, find the min indentation of non-blank lines, and strip that indentation from all lines.)
* - Added __docformat__Edward Loper2004-08-121-13/+27
| | | | | | | - Added comments for some regexps - If the traceback type/message don't match, then still print full traceback in report_failure (not just the first & last lines) - Renamed DocTestRunner.__failure_header -> _failure_header
* - Changed option directives to be example-specific. (i.e., they nowEdward Loper2004-08-121-50/+101
| | | | | | | | | modify option flags for a single example; they do not turn options on or off.) - Added "indent" and "options" attributes for Example - Got rid of add_newlines param to DocTestParser._parse_example (it's no longer needed; Example's constructor now takes care of it). - Added some docstrings
* - Added a register_optionflag function (so users can add their ownEdward Loper2004-08-121-22/+18
| | | | | option flags); and use it to define the existing optionflag constants.
* Start rewriting doctest's LaTeX docs. Damn, this is slow going!Tim Peters2004-08-101-1/+1
|
* Edward's latest checkins somehow managed to wipe out my previous latestTim Peters2004-08-091-14/+17
| | | | checkins. Reapplying the latter changes.
* - DocTest is now a simple container class; its constructor is no longerEdward Loper2004-08-091-98/+101
| | | | | | | | | | | responsible for parsing the string. - Renamed Parser to DocTestParser - DocTestParser.get_*() now accept the string & name as command-line arguments; the parser's constructor is now empty. - Added DocTestParser.get_doctest() method - Replaced "doctest_factory" argument to DocTestFinder with a "parser" argument (takes a DocTestParser). - Changed _tag_msg to take an indentation string argument.
* This started as a spelling and whitespace cleanup. The comment forTim Peters2004-08-091-14/+17
| | | | | | | | | the set_trace fiddling didn't make sense to me, and I ended up reworking that part of the code. We really do want to save and restore pdb.set_trace, so that each dynamically nested level of doctest gets sys.stdout fiddled to what's appropriate for *it*. The only "trick" really needed is that these layers of set_trace wrappers each call the original pdb.set_trace (instead of the current pdb.set_trace).
* Added support for pdb.set_trace.Jim Fulton2004-08-091-1/+16
|
* Removed lots of stuff from the module docstring. My intent for 2.4 isTim Peters2004-08-091-137/+18
| | | | | to put details in the LaTeX docs instead, and lots of stuff in the module docstring wasn't useful anyway.
* Repair some out-of-date comments.Tim Peters2004-08-091-8/+2
|
* Drop the excruciating newline requirements on arguments toTim Peters2004-08-091-15/+15
| | | | | | Example.__init__. The constructor now adds trailing newlines when needed, and no longer distinguishes between multi- and single-line cases for source.
* Give return stmts their own lines.Tim Peters2004-08-091-2/+4
|
* Indent body of _EXAMPLE_RE for readability. _IS_BLANK_OR_COMMENT makesTim Peters2004-08-091-13/+13
| | | | more sense as a callable.
* Changed Parser.get_examples() to return a list of Example objects,Edward Loper2004-08-091-21/+13
| | | | rather than a list of triples.
* - Split DocTestRunner's check_output and output_difference methods offEdward Loper2004-08-091-127/+139
| | | | | | into their own class, OutputChecker. - Added optional OutputChecker arguments to DocTestRunner, DocTestCase, DocTestSuite.
* Rewrote Parser, using regular expressions instead of walking thoughEdward Loper2004-08-091-219/+216
| | | | | | | | | the string one line at a time. The resulting code is (in my opinion, anyway), much easier to read. In the process, I found and fixed a bug in the orginal parser's line numbering in error messages (it was inconsistant between 0-based and 1-based). Also, check for missing blank lines after the prompt on all prompt lines, not just PS1 lines (test added).
* Get rid of the ignore_imports argument to DocTestFinder.find().Tim Peters2004-08-081-25/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This got slammed in when find() was fixed to stop grabbing doctests from modules imported *by* the module being tested. Such tests cannot be expected to succeed, since they'll be run with the current module's globals. Dozens of Zope3 doctests were failing because of that. It wasn't clear why ignore_imports got added then. Maybe it's because some existing tests failed when the change was made. Whatever, it's a Bad Idea so it's gone now. The only use of it was exceedingly obscure, in test_doctest's "Duplicate Removal" test. It was "needed" there because, as an artifact of running a doctest inside a doctest, the func_globals of functions compiled in the second-level doctest don't match the module globals, and so the test-finder believed these functions were from a foreign module and skipped them. But that took a long time to figure out, and I actually understand some of this stuff <0.9 wink>. That problem was resolved by moving the source code for the second-level doctest into an actual module (test/doctest_aliases.py). The only remaining difficulty was that the test for the deprecated Tester.rundict() then failed, because the test finder doesn't take module=None at face value, trying to guess which module the user really intended then. Its guess wasn't appropriate for what Tester.rundict needs when module=None is given to *it*, which is "no, there is no module here, and I mean it". So now passing module=False means exactly that. This is hokey, but ignore_imports=False was really a hack to worm around that there was no way to tell the test-finder that module=None *sometimes* means what it says. There was no use case for the combination of passing a real module with ignore_imports=False.
* Type in docstring.Tim Peters2004-08-081-1/+1
|
* Also deprecated the old Tester class, which is no longer used by anythingTim Peters2004-08-081-2/+13
| | | | except internal tests.
* Deprecate the doctest.is_private() function.Tim Peters2004-08-081-0/+6
|
* Deprecated testmod's useless & confusing isprivate gimmick.Tim Peters2004-08-081-40/+24
| | | | | | | Ripped out the docs for the new DocTestFinder's namefilter argument, and renamed it to _namefilter; this only existed to support isprivate. Removed the new DocTestFinder's objfilter argument. No point adding more cruft to a broken filtering design.
* Whitespace normalization.Tim Peters2004-08-071-2/+2
|
* Merging from tim-doctest-branch, which is now closed.Tim Peters2004-08-061-180/+652
| | | | | | This primarily adds more powerful ways to work with unittest, including spiffy support for building suites out of doctests in non-Python "text files".
* Example.__init__: this cannot use assert, because that fails to triggerTim Peters2004-08-041-2/+5
| | | | | in a -O run, and so test_doctest was failing under -O. Simple cause, simple cure.
* Edward Loper's cool and massive refactoring of doctest.py, merged fromTim Peters2004-08-041-943/+1373
| | | | | | | | the tim-doctest-merge-24a2 tag on the the tim-doctest-branch branch. We did development on the branch in case it wouldn't land in time for 2.4a2, but the branch looked good: Edward's tests passed there, ditto Python's tests, and ditto the Zope3 tests. Together, those hit doctest heavily.
* Ported some features from zope:Jim Fulton2004-07-141-101/+214
| | | | | - Fixed the display of tests in verbose output - Allow setUp and tearDown functions to be provided for DocTestSuites.
* Whitespace normalization.Tim Peters2004-07-071-3/+3
|
* Patch #932930: suggest the use of rawstrings for backslashes.Martin v. Löwis2004-05-311-12/+21
|
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-13/+11
| | | | From SF patch #852334.
* SF patch #806246: use basestring where possibleRaymond Hettinger2003-09-171-1/+1
| | | | (Contributed by George Yoshida.)