classification
Title: test_doctest.py fails with unexpected results in doctest.testfile
Type: behavior Stage: committed/rejected
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: test_doctest fails when run in verbose mode
View: 1729305
Assigned To: Nosy List: Martin.Ducár, r.david.murray
Priority: normal Keywords:

Created on 2010-03-16 14:58 by Martin.Ducár, last changed 2010-03-16 16:37 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
python26_test_doctest.log Martin.Ducár, 2010-03-16 14:58 full log
Messages (2)
msg101170 - (view) Author: Martin Ducár (Martin.Ducár) Date: 2010-03-16 14:58
During python regrtest.py i have found that doctest test module does not count with expected output when using testfile test_doctest.txt. Example output of the test:
---------------------------------------------------------------------
File "/usr/lib/python2.6/test/test_doctest.py", line 2146, in test.test_doctest.test_testfile
Failed example:
    doctest.testfile('test_doctest.txt') # doctest: +ELLIPSIS
Expected:
    **********************************************************************
    File "...", line 6, in test_doctest.txt
    Failed example:
        favorite_color
    Exception raised:
        ...
        NameError: name 'favorite_color' is not defined
    **********************************************************************
    1 items had failures:
       1 of   2 in test_doctest.txt
    ***Test Failed*** 1 failures.
    TestResults(failed=1, attempted=2)
Got:
    Trying:
        favorite_color
    Expecting:
        'blue'
    **********************************************************************
    File "/usr/lib/python2.6/test/test_doctest.txt", line 6, in test_doctest.txt
    Failed example:
        favorite_color
    Exception raised:
        Traceback (most recent call last):
          File "/usr/lib/python2.6/doctest.py", line 1241, in __run
            compileflags, 1) in test.globs
          File "<doctest test_doctest.txt[0]>", line 1, in <module>
            favorite_color
        NameError: name 'favorite_color' is not defined
    Trying:
        if 1:
           print 'a'
           print
           print 'b'
    Expecting:
        a
        <BLANKLINE>
        b
    ok
    **********************************************************************
    1 items had failures:
       1 of   2 in test_doctest.txt
    2 tests in 1 items.
    1 passed and 1 failed.
    ***Test Failed*** 1 failures.
    TestResults(failed=1, attempted=2)
---------------------------------------------------------------------
There are two test cases  in that file and it count's only with the output of the one, another similar failed testcases from test_doctest.py are:
---------------------------------------------------------------------
File "/usr/lib/python2.6/test/test_doctest.py", line 2168, in test.test_doctest.test_testfile
Failed example:
    doctest.testfile('test_doctest.txt', globs=globs)
...
File "/usr/lib/python2.6/test/test_doctest.py", line 2173, in test.test_doctest.test_testfile
Failed example:
    doctest.testfile('test_doctest.txt', globs=globs,
                     extraglobs=extraglobs) # doctest: +ELLIPSIS
...
File "/usr/lib/python2.6/test/test_doctest.py", line 2193, in test.test_doctest.test_testfile
Failed example:
    doctest.testfile('test_doctest.txt', globs=globs,
                     module_relative='test')
...
File "/usr/lib/python2.6/test/test_doctest.py", line 2227, in test.test_doctest.test_testfile
Failed example:
    doctest.testfile('test_doctest.txt', name='newname')
    # doctest: +ELLIPSIS
...
File "/usr/lib/python2.6/test/test_doctest.py", line 2238, in test.test_doctest.test_testfile
Failed example:
    doctest.testfile('test_doctest.txt', report=False)
    # doctest: +ELLIPSIS
...
File "/usr/lib/python2.6/test/test_doctest.py", line 2264, in test.test_doctest.test_testfile
Failed example:
    doctest.testfile('test_doctest4.txt') # doctest: +ELLIPSIS
---------------------------------------------------------------------



---------------------------------------------------------------------
# cat /usr/lib/python2.6/test/test_doctest.py
This is a sample doctest in a text file.

In this example, we'll rely on a global variable being set for us
already:

  >>> favorite_color
  'blue'

We can make this fail by disabling the blank-line feature.

  >>> if 1:
  ...    print 'a'
  ...    print
  ...    print 'b'
  a
  <BLANKLINE>
  b
---------------------------------------------------------------------

This fails on python version 2.6.4. OS tried Arch linux and OpenSolaris, failed on both the same way. Full log in attachment

Testsuite run with -v argument:
# python2.6 /usr/lib/python2.6/test/test_doctest.py -v
msg101174 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-03-16 16:37
This is a duplicate of issue 1729305.
History
Date User Action Args
2010-03-16 16:37:27r.david.murraysetstatus: open -> closed
priority: normal
superseder: test_doctest fails when run in verbose mode


nosy: + r.david.murray
messages: + msg101174
resolution: duplicate
stage: committed/rejected
2010-03-16 14:58:57Martin.Ducárcreate