I ran doctests on the interactive session scripts from the tutorial.
Aside from finding a doctest enhancement---but there are already so
many doctest issues tracked---I found these discrepancies using online
tutorial and Python 3.0rc1 (r30rc1:66499, Oct 17 2008, 13:11:34)
-1--1--1--1--1--1--1--1--1--1--1--1--1--1--1--1--1--1--1--1--1--
"doesn't" --> "does not" Trite documentation error
http://docs.python.org/dev/3.0/tutorial/introduction.html
Time to fix the doctest EXCEPTION_DETAIL
TypeError: 'str' object doesn't support ... (multiple occurrences)
"doesn't" became "does not" in release 2.4.
-2--2--2--2--2--2--2--2--2--2--2--2--2--2--2--2--2--2--2--2--2--
"coercing to Unicode" or "convert to str"?
$ p3
Python 3.0rc1 (r30rc1:66499, Oct 17 2008, 13:11:34)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> '2'+3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't convert 'int' object to str implicitly
http://docs.python.org/dev/3.0/tutorial/errors.html
>>> '2' + 2
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: coercing to Unicode: need string or buffer, int found
-3--3--3--3--3--3--3--3--3--3--3--3--3--3--3--3--3--3--3--3--3--
Integer division yields float
http://docs.python.org/dev/3.0/tutorial/errors.html
>>> divide(2, 1) # 2.0 is correct
result is 2
-doctest---doctest---doctest---doctest---doctest---doctest--
doctest improvement possible
# execute this as sh code to exhibit problem
cat<<EOF>p.py
'''
example from
http://docs.python.org/dev/3.0/tutorial/introduction.html
>>> 'doesn\'t'
"doesn't"
'''
import doctest
doctest.testmod()
EOF
python p.py
# "\"Yes,\" he said." # likewise breaks doctest
# end of sh scripting
I suppose these issues are known. Here's another that fails in
doctest:
http://docs.python.org/dev/3.0/tutorial/stdlib.html
>>> re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest')
['foot', 'fell', 'fastest']
|