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.

Title: doctest seems to always fail on numpy.array2string
Type: behavior Stage:
Components: Tests Versions: Python 2.5
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.

File name Uploaded Description Edit 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

Failed example:
    [0 1]
    '[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
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]
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