This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: doctest seems to always fail on numpy.array2string
Type: behavior Stage:
Components: Tests Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, ekorn
Priority: normal Keywords:

Created on 2008-12-05 11:45 by ekorn, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_doctest.py ekorn, 2008-12-05 11:45 doctest fails to recognize correct output from numpy.array2string()
Messages (2)
msg77006 - (view) Author: (ekorn) Date: 2008-12-05 11:45
I don't understand this doctest error, resulting from
python test_doctest.py

Failed example:
    numpy.array2string(numpy.arange(2))
Expected:
    [0 1]
Got:
    '[0 1]'

The specified output was copied-and-pasted directly from running the 
example. Whitespace seems identical and #doctest: +NORMALIZE_WHITESPACE 
does not help.
msg77015 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-12-05 13:22
Doctest output scrupulously follows the output of an interactive session
of python.

On my machine:

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.array2string(numpy.arange(2))
'[0 1]'
>>>

The the interactive session does not simply print objects, it calls
repr() on them, so that you can make the distinction between the number
0 and the string "0".

You should add quotes to your doctest string, or use print:

>>> import numpy
>>> print numpy.array2string(numpy.arange(2))
[0 1]
History
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48795
2008-12-05 13:22:48amaury.forgeotdarcsetstatus: open -> closed
resolution: not a bug
messages: + msg77015
nosy: + amaury.forgeotdarc
2008-12-05 11:45:54ekorncreate