[Patches] [ python-Patches-932935 ] doctest: allow custom matchers for testing if got==want

SourceForge.net noreply at sourceforge.net
Thu Sep 2 15:19:48 CEST 2004


Patches item #932935, was opened at 2004-04-10 19:57
Message generated for change (Settings changed) made by jhylton
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=932935&group_id=5470

Category: Library (Lib)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Edward Loper (edloper)
>Assigned to: Edward Loper (edloper)
Summary: doctest: allow custom matchers for testing if got==want

Initial Comment:
To determine the success of a doctest example, 
doctest compares the
actual output to the expected output.  The test 
succeeds if the two
match exactly.

This patch gives the user the ability to supply a 
custom "matcher"
function, which will be used instead of string equality 
to test
whether the test succeeds.  This function should take 
two string
parameters, "got" and "want", which will contain the 
actual and
expected output, respectively; and it should return 
True if they
should be considered to match (i.e., test succeeds), 
and False if they
should not (i.e., test fails).

Two sample matcher functions are provided, as well:
  - match_ignoring_whitespace returns true if the 
actual output
    and expected output are equal, ignoring 
differences in amount
    of whitespace (eg 2 spaces vs 1).

  - match_ignoring_trailing_blanklines returns true if 
the actual
    output and expected output are equal, once any 
trailing blank
    lines are discarded.  This can be useful with the 
END_WITH_DEDENT
    option, suggested in patch #932933 [1]

The patch was made avainst revision 1.33 of 
doctest.py.

[1] http://sourceforge.net/tracker/index.php?
func=detail&aid=932933&group_id=5470&atid=3054
70

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-05-31 19:04

Message:
Logged In: YES 
user_id=21627

Please resubmit the patch using unified diffs. You might
just as well include test cases and documentation right away.

----------------------------------------------------------------------

Comment By: Edward Loper (edloper)
Date: 2004-04-10 20:00

Message:
Logged In: YES 
user_id=195958

If this patch looks good, I'd be happy to write a patch for 
the docs & test cases.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=932935&group_id=5470


More information about the Patches mailing list