summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
Commit message (Collapse)AuthorAgeFilesLines
* The distinction between comparison flags and reporting flags isn't uniqueTim Peters2004-08-301-28/+19
| | | | | | | | | | | to unittest, so make it official: new module constants COMPARISON_FLAGS and REPORTING_FLAGS, which are bitmasks or'ing together the relevant individual option flags. set_unittest_reportflags(): Reworked to use REPORTING_FLAGS, and simplified overly complicated flag logic. class FakeModule: Removed this; neither documented nor used.
* Whitespace normalization.Tim Peters2004-08-291-8/+8
|
* - setUp and tearDown functions are now passed the test objectJim Fulton2004-08-281-17/+124
| | | | | - Added a set_unittest_reportflags to set default reporting flags used when running doctests under unittest control.
* Remove unused method _OutputRedirectingPdb.resumeEdward Loper2004-08-271-3/+0
|
* - Removed redundant call to expandtabs in DocTestParesr.Edward Loper2004-08-271-16/+61
| | | | | | | | | | | | | | - 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-143/+80
| | | | | | | | | 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-2/+2
| | | | | | | | 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.
* _do_a_fancy_diff(): Pay no attention to the ellipses behind the curtain.Tim Peters2004-08-261-7/+11
| | | | | | | | | While a fancy diff can be confusing in the presence of ellipses, so far I'm finding (2-0-0) that it's much more a major aid in narrowing down the possibilities when an ellipsis-slinging test fails. So we no longer refuse to do a fancy diff just because of ellipses. This isn't ideal; it's just better.
* Changed OutputChecker.output_difference to expect an Example object,Edward Loper2004-08-261-6/+6
| | | | | | rather than an expected output string. This gives the output_difference method access to more information, such as the indentation of the example, which might be useful.
* Added REPORT_ONLY_FIRST_FAILURE flag, which supresses output after theEdward Loper2004-08-261-10/+22
| | | | first failing example in each test.
* Renamed UNIFIED_DIFF->REPORT_UDIFF; CONTEXT_DIFF->REPORT_CDIFF; andEdward Loper2004-08-261-16/+16
| | | | | | | 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/+6
|
* - Changed the output of report_start() and report_unexpected_exception()Edward Loper2004-08-261-36/+24
| | | | | | | 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-43/+62
| | | | | | | | | 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-12/+8
| | | | | | | | 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.
* The attempt to shut up deprecation warnings for doctest's own use ofTim Peters2004-08-231-2/+5
| | | | | is_private in its tests failed if doctest.py was run directly. Now it works.
* 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.