summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Removed outdated commentEdward Loper2004-08-271-2/+0
|
* - Removed redundant call to expandtabs in DocTestParesr.Edward Loper2004-08-271-51/+114
| | | | | | | | | | | | | | - Improvements to interactive debugging support: - Changed the replacement pdb.set_trace to redirect stdout to the real stdout *only* during interactive debugging; stdout from code continues to go to the fake stdout. - When the interactive debugger gets to the end of an example, automatically continue. - Use a replacement linecache.getlines that will return source lines from doctest examples; this makes the source available to the debugger for interactive debugging. - In test_doctest, use a specialized _FakeOutput class instead of a temporary file to fake stdin for the interactive interpreter.
* - Added DocTestParser.parse(), which parses a docstring into ExamplesEdward Loper2004-08-261-2/+57
| | | | | | | | | and intervening text strings. - Removed DocTestParser.get_program(): use script_from_examples() instead. - Fixed bug in DocTestParser._INDENT_RE - Fixed bug in DocTestParser._min_indent - Moved _want_comment() to the utility function section
* output_difference(): In fancy-diff cases, the way this split expected &Tim Peters2004-08-261-7/+3
| | | | | | | | actual output into lines created spurious empty lines at the ends of each. Those matched, but the fancy diffs had surprising line counts (1 larger than expected), and tests kept having to slam <BLANKLINE> into the expected output to account for this. Using the splitlines() string method with keepends=True instead accomplishes what was intended directly.
* Added REPORT_ONLY_FIRST_FAILURE flag, which supresses output after theEdward Loper2004-08-261-0/+81
| | | | first failing example in each test.
* Renamed UNIFIED_DIFF->REPORT_UDIFF; CONTEXT_DIFF->REPORT_CDIFF; andEdward Loper2004-08-261-7/+7
| | | | | | | NDIFF_DIFF->REPORT_NDIFF. This establishes the naming convention that all reporting options should begin with "REPORT_" (since reporting options are a different class from output comparison options; but they are both set in optionflags).
* Shortened diff output for unified & context diffsEdward Loper2004-08-261-6/+2
|
* - Changed the output of report_start() and report_unexpected_exception()Edward Loper2004-08-261-22/+40
| | | | | | | to be more consistent with report_failure() - If `want` or `got` is empty, then print "Expected nothing\n" or "Got nothing\n" rather than "Expected:\n" or "Got:\n" - Got rid of _tag_msg
* Added an "exc_msg" attribute to Example (containing the expectedEdward Loper2004-08-261-16/+77
| | | | | | | | | exception message, or None if no exception is expected); and moved exception parsing from DocTestRunner to DocTestParser. This is architecturally cleaner, since it moves all parsing work to DocTestParser; and it should make it easier for code outside DocTestRunner (notably debugging code) to properly handle expected exceptions.
* Only recognize the expected output as an exception if it *starts* withEdward Loper2004-08-251-3/+13
| | | | | | | | a traceback message. I.e., examples that raise exceptions may no longer generate pre-exception output. This restores the behavior of doctest in python 2.3. The ability to check pre-exception output is being removed because it makes the documentation simpler; and because there are very few use cases for it.
* test_DocTestFinder(): This test failed when test_doctest was runTim Peters2004-08-231-2/+5
| | | | | directly, due to assuming a filename specific to running tests "the normal way". +ELLIPSIS to the rescue!
* Moved some test cases from doctest to test_doctest.Tim Peters2004-08-231-2/+126
|
* Added NDIFF_DIFF option.Tim Peters2004-08-221-3/+29
|
* Bugs fixed:Jim Fulton2004-08-221-56/+115
| | | | | | | | | | | | | | | - 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-28/+5
| | | | | | 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.
* Now that they've settled down, document doctest directives.Tim Peters2004-08-191-3/+17
|
* Replaced the ELLIPSIS implementation with a worst-case linear-time one.Tim Peters2004-08-191-8/+20
|
* ELLIPSIS implementation: an ellipsis couldn't match nothing if itTim Peters2004-08-191-0/+23
| | | | | | | 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-2/+25
| | | | | updating line numbers correctly for bare prompts & examples containing only comments).
* - Changed output of DocTestParser.get_program() to make it easier toEdward Loper2004-08-121-8/+8
| | | | | | | | 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-4/+6
| | | | | | | - 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-29/+153
| | | | | | | | | 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
* Edward's latest checkins somehow managed to wipe out my previous latestTim Peters2004-08-091-1/+0
| | | | checkins. Reapplying the latter changes.
* - DocTest is now a simple container class; its constructor is no longerEdward Loper2004-08-091-7/+10
| | | | | | | | | | | 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-6/+5
| | | | | | | | | 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-0/+87
|
* Drop the excruciating newline requirements on arguments toTim Peters2004-08-091-17/+27
| | | | | | Example.__init__. The constructor now adds trailing newlines when needed, and no longer distinguishes between multi- and single-line cases for source.
* Rewrote Parser, using regular expressions instead of walking thoughEdward Loper2004-08-091-2/+11
| | | | | | | | | 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-16/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Deprecated testmod's useless & confusing isprivate gimmick.Tim Peters2004-08-081-21/+8
| | | | | | | 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.
* Bug 772091: doctest.DocTestSuite does not support __test__Tim Peters2004-08-071-13/+16
| | | | | This got fixed "by magic" as part of the refactoring, but wasn't tested as such. Now it is.
* Merging from tim-doctest-branch, which is now closed.Tim Peters2004-08-061-2/+177
| | | | | | 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-3/+3
| | | | | 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-2/+1002
| | | | | | | | 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.
* Get rid of relative imports in all unittests. Now anything thatBarry Warsaw2002-07-231-1/+2
| | | | | | | | | | | imports e.g. test_support must do so using an absolute package name such as "import test.test_support" or "from test import test_support". This also updates the README in Lib/test, and gets rid of the duplicate data dirctory in Lib/test/data (replaced by Lib/email/test/data). Now Tim and Jack can have at it. :)
* Whitespace normalization.Tim Peters2001-09-181-1/+1
|
* Teach regrtest how to pass on doctest failure msgs. This is done via aTim Peters2001-09-091-3/+2
| | | | | | | | | | | horridly inefficient hack in regrtest's Compare class, but it's about as clean as can be: regrtest has to set up the Compare instance before importing a test module, and by the time the module *is* imported it's too late to change that decision. The good news is that the more tests we convert to unittest and doctest, the less the inefficiency here matters. Even now there are few tests with large expected-output files (the new cost here is a Python-level call per .write() when there's an expected- output file).
* Remove test_doctest's expected-output file.Tim Peters2001-05-231-1/+2
| | | | | | Change test_doctest and test_difflib to pass regrtest's notion of verbosity on to doctest. Add explanation for a dozen "new" things to test/README.
* Add std test for doctest.Tim Peters2001-02-101-0/+2