mirror of https://github.com/python/cpython
Get doctest to pass. The problem was int/int -> float now. There
were some cases where an int was assumed. Also had to change the string of the exception when dividing and int by zero. Not sure what the best error message should be. Currently 5 / 0 yields the message: ZeroDivisionError: float division That isn't entirely correct. But I'm not sure what else to do.
This commit is contained in:
parent
57c179c5b9
commit
914a81841f
|
@ -605,7 +605,7 @@ DocTestFinder finds the line number of each example:
|
||||||
... ... print x,
|
... ... print x,
|
||||||
... 0 1 2 3 4 5 6 7 8 9
|
... 0 1 2 3 4 5 6 7 8 9
|
||||||
... >>> x/2
|
... >>> x/2
|
||||||
... 6
|
... 6.0
|
||||||
... '''
|
... '''
|
||||||
>>> test = doctest.DocTestFinder().find(f)[0]
|
>>> test = doctest.DocTestFinder().find(f)[0]
|
||||||
>>> [e.lineno for e in test.examples]
|
>>> [e.lineno for e in test.examples]
|
||||||
|
@ -680,7 +680,7 @@ statistics. Here's a simple DocTest case we can use:
|
||||||
... >>> print x
|
... >>> print x
|
||||||
... 12
|
... 12
|
||||||
... >>> x/2
|
... >>> x/2
|
||||||
... 6
|
... 6.0
|
||||||
... '''
|
... '''
|
||||||
>>> test = doctest.DocTestFinder().find(f)[0]
|
>>> test = doctest.DocTestFinder().find(f)[0]
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ the failure and proceeds to the next example:
|
||||||
... >>> print x
|
... >>> print x
|
||||||
... 14
|
... 14
|
||||||
... >>> x/2
|
... >>> x/2
|
||||||
... 6
|
... 6.0
|
||||||
... '''
|
... '''
|
||||||
>>> test = doctest.DocTestFinder().find(f)[0]
|
>>> test = doctest.DocTestFinder().find(f)[0]
|
||||||
>>> doctest.DocTestRunner(verbose=True).run(test)
|
>>> doctest.DocTestRunner(verbose=True).run(test)
|
||||||
|
@ -725,7 +725,7 @@ the failure and proceeds to the next example:
|
||||||
Trying:
|
Trying:
|
||||||
x/2
|
x/2
|
||||||
Expecting:
|
Expecting:
|
||||||
6
|
6.0
|
||||||
ok
|
ok
|
||||||
(1, 3)
|
(1, 3)
|
||||||
"""
|
"""
|
||||||
|
@ -739,7 +739,7 @@ output:
|
||||||
... >>> print x
|
... >>> print x
|
||||||
... 12
|
... 12
|
||||||
... >>> x/2
|
... >>> x/2
|
||||||
... 6
|
... 6.0
|
||||||
... '''
|
... '''
|
||||||
>>> test = doctest.DocTestFinder().find(f)[0]
|
>>> test = doctest.DocTestFinder().find(f)[0]
|
||||||
|
|
||||||
|
@ -756,7 +756,7 @@ output:
|
||||||
Trying:
|
Trying:
|
||||||
x/2
|
x/2
|
||||||
Expecting:
|
Expecting:
|
||||||
6
|
6.0
|
||||||
ok
|
ok
|
||||||
(0, 3)
|
(0, 3)
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ iff `-v` appears in sys.argv:
|
||||||
Trying:
|
Trying:
|
||||||
x/2
|
x/2
|
||||||
Expecting:
|
Expecting:
|
||||||
6
|
6.0
|
||||||
ok
|
ok
|
||||||
(0, 3)
|
(0, 3)
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ replaced with any other string:
|
||||||
... >>> x = 12
|
... >>> x = 12
|
||||||
... >>> print x/0
|
... >>> print x/0
|
||||||
... Traceback (most recent call last):
|
... Traceback (most recent call last):
|
||||||
... ZeroDivisionError: integer division or modulo by zero
|
... ZeroDivisionError: float division
|
||||||
... '''
|
... '''
|
||||||
>>> test = doctest.DocTestFinder().find(f)[0]
|
>>> test = doctest.DocTestFinder().find(f)[0]
|
||||||
>>> doctest.DocTestRunner(verbose=False).run(test)
|
>>> doctest.DocTestRunner(verbose=False).run(test)
|
||||||
|
@ -825,7 +825,7 @@ unexpected exception:
|
||||||
... >>> print 'pre-exception output', x/0
|
... >>> print 'pre-exception output', x/0
|
||||||
... pre-exception output
|
... pre-exception output
|
||||||
... Traceback (most recent call last):
|
... Traceback (most recent call last):
|
||||||
... ZeroDivisionError: integer division or modulo by zero
|
... ZeroDivisionError: float division
|
||||||
... '''
|
... '''
|
||||||
>>> test = doctest.DocTestFinder().find(f)[0]
|
>>> test = doctest.DocTestFinder().find(f)[0]
|
||||||
>>> doctest.DocTestRunner(verbose=False).run(test)
|
>>> doctest.DocTestRunner(verbose=False).run(test)
|
||||||
|
@ -836,7 +836,7 @@ unexpected exception:
|
||||||
print 'pre-exception output', x/0
|
print 'pre-exception output', x/0
|
||||||
Exception raised:
|
Exception raised:
|
||||||
...
|
...
|
||||||
ZeroDivisionError: integer division or modulo by zero
|
ZeroDivisionError: float division
|
||||||
(1, 2)
|
(1, 2)
|
||||||
|
|
||||||
Exception messages may contain newlines:
|
Exception messages may contain newlines:
|
||||||
|
@ -933,7 +933,7 @@ unexpected exception:
|
||||||
Exception raised:
|
Exception raised:
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
ZeroDivisionError: integer division or modulo by zero
|
ZeroDivisionError: float division
|
||||||
(1, 1)
|
(1, 1)
|
||||||
"""
|
"""
|
||||||
def optionflags(): r"""
|
def optionflags(): r"""
|
||||||
|
|
Loading…
Reference in New Issue