New submission from Martin Ducár <duca...@gmail.com>:

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

----------
components: Library (Lib)
files: python26_test_doctest.log
messages: 101170
nosy: Martin.Ducár
severity: normal
status: open
title: test_doctest.py fails with unexpected results in doctest.testfile
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file16562/python26_test_doctest.log

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to