[issue13349] Uninformal error message in index() and remove() functions
Éric Araujo
report at bugs.python.org
Mon Nov 7 17:49:00 CET 2011
Éric Araujo <merwok at netwok.org> added the comment:
> There's also documentation and tests that depend on this actual error message:
> Doc/library/doctest.rst: ValueError: list.remove(x): x not in list
> Lib/test>/test_xml_etree.py: ValueError: list.remove(x): x not in list
That’s a well-known doctest problem. Just update the doc. Writing robust doctests is an art:
>>> str(someobject)
'output that can change'
>>> 'something I want' in str(someobject) # more robust, but less useful if it fails
True
>>> something.index(spam)
traceback blah:
ValueError: output that can change
>>> try: something.index(spam)
... except ValueError: print('spam not in something') # more robust, but ugly
spam not in something
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13349>
_______________________________________
More information about the Python-bugs-list
mailing list