Search code examples
pythonnosetests

AssertionError in nosetests


When I start tests with

nosetests --with-doctest --doctest-extension=txt

I got this error.

F
======================================================================
FAIL: Doctest: README.txt
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/doctest.py", line 2152, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for README.txt
  File "/home/xralf/example/README.txt", line 0

How should I repair this error? Is it something bad with test (because it's line 0)

thank you


Solution

  • In the README.txt file there should be more whitespace, especially after the statements that don't return a value (like import statements).

    =============
    example
    =============
    >>> a = 3
    >>> a - 1
    2
    >>> from sqlite3 import dbapi2 as sqlite
    
    some text
    

    Important is the space after import statement. Without it this won't work.