diff options
author | Edward Loper <edloper@gradient.cis.upenn.edu> | 2004-08-26 02:45:51 (GMT) |
---|---|---|
committer | Edward Loper <edloper@gradient.cis.upenn.edu> | 2004-08-26 02:45:51 (GMT) |
commit | a89f88d53fc83b3eb6788a6e70e0eb05a58703ed (patch) | |
tree | 1302eecf3acad5eacc1153fab8c8c9c0fc52ba22 /Lib/test | |
parent | cc8a4f6563395e39d77da9888d0ea3675214ca64 (diff) | |
download | cpython-a89f88d53fc83b3eb6788a6e70e0eb05a58703ed.zip cpython-a89f88d53fc83b3eb6788a6e70e0eb05a58703ed.tar.gz cpython-a89f88d53fc83b3eb6788a6e70e0eb05a58703ed.tar.bz2 |
Added REPORT_ONLY_FIRST_FAILURE flag, which supresses output after the
first failing example in each test.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_doctest.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index d683051..2464b23 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -1042,6 +1042,87 @@ marking, as well as interline differences. ? + ++ ^ <BLANKLINE> (1, 1) + +The REPORT_ONLY_FIRST_FAILURE supresses result output after the first +failing example: + + >>> def f(x): + ... r''' + ... >>> print 1 # first success + ... 1 + ... >>> print 2 # first failure + ... 200 + ... >>> print 3 # second failure + ... 300 + ... >>> print 4 # second success + ... 4 + ... >>> print 5 # third failure + ... 500 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ********************************************************************** + Line 4, in f + Failed example: + print 2 # first failure + Expected: + 200 + Got: + 2 + (3, 5) + +However, output from `report_start` is not supressed: + + >>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test) + Trying: + print 1 # first success + Expecting: + 1 + ok + Trying: + print 2 # first failure + Expecting: + 200 + ********************************************************************** + Line 4, in f + Failed example: + print 2 # first failure + Expected: + 200 + Got: + 2 + (3, 5) + +For the purposes of REPORT_ONLY_FIRST_FAILURE, unexpected exceptions +count as failures: + + >>> def f(x): + ... r''' + ... >>> print 1 # first success + ... 1 + ... >>> raise ValueError(2) # first failure + ... 200 + ... >>> print 3 # second failure + ... 300 + ... >>> print 4 # second success + ... 4 + ... >>> print 5 # third failure + ... 500 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + Line 4, in f + Failed example: + raise ValueError(2) # first failure + Exception raised: + ... + ValueError: 2 + (3, 5) + """ def option_directives(): r""" |