Commit bdc36e4d authored by Guido van Rossum's avatar Guido van Rossum

Redue the failure rate to 13 tests. Bah.

parent 0bcbb0d4
...@@ -166,10 +166,10 @@ Example is a simple container class that holds: ...@@ -166,10 +166,10 @@ Example is a simple container class that holds:
These attributes are set by the constructor. `source` and `want` are These attributes are set by the constructor. `source` and `want` are
required; the other attributes all have default values: required; the other attributes all have default values:
>>> example = doctest.Example('print 1', '1\n') >>> example = doctest.Example('print(1)', '1\n')
>>> (example.source, example.want, example.exc_msg, >>> (example.source, example.want, example.exc_msg,
... example.lineno, example.indent, example.options) ... example.lineno, example.indent, example.options)
('print 1\n', '1\n', None, 0, 0, {}) ('print(1)\n', '1\n', None, 0, 0, {})
The first three attributes (`source`, `want`, and `exc_msg`) may be The first three attributes (`source`, `want`, and `exc_msg`) may be
specified positionally; the remaining arguments should be specified as specified positionally; the remaining arguments should be specified as
...@@ -186,22 +186,22 @@ keyword arguments: ...@@ -186,22 +186,22 @@ keyword arguments:
The constructor normalizes the `source` string to end in a newline: The constructor normalizes the `source` string to end in a newline:
Source spans a single line: no terminating newline. Source spans a single line: no terminating newline.
>>> e = doctest.Example('print 1', '1\n') >>> e = doctest.Example('print(1)', '1\n')
>>> e.source, e.want >>> e.source, e.want
('print 1\n', '1\n') ('print(1)\n', '1\n')
>>> e = doctest.Example('print 1\n', '1\n') >>> e = doctest.Example('print(1)\n', '1\n')
>>> e.source, e.want >>> e.source, e.want
('print 1\n', '1\n') ('print(1)\n', '1\n')
Source spans multiple lines: require terminating newline. Source spans multiple lines: require terminating newline.
>>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n') >>> e = doctest.Example('print(1);\nprint(2)\n', '1\n2\n')
>>> e.source, e.want >>> e.source, e.want
('print 1;\nprint 2\n', '1\n2\n') ('print(1);\nprint(2)\n', '1\n2\n')
>>> e = doctest.Example('print 1;\nprint 2', '1\n2\n') >>> e = doctest.Example('print(1);\nprint(2)', '1\n2\n')
>>> e.source, e.want >>> e.source, e.want
('print 1;\nprint 2\n', '1\n2\n') ('print(1);\nprint(2)\n', '1\n2\n')
Empty source string (which should never appear in real examples) Empty source string (which should never appear in real examples)
>>> e = doctest.Example('', '') >>> e = doctest.Example('', '')
...@@ -211,13 +211,13 @@ The constructor normalizes the `source` string to end in a newline: ...@@ -211,13 +211,13 @@ The constructor normalizes the `source` string to end in a newline:
The constructor normalizes the `want` string to end in a newline, The constructor normalizes the `want` string to end in a newline,
unless it's the empty string: unless it's the empty string:
>>> e = doctest.Example('print 1', '1\n') >>> e = doctest.Example('print(1)', '1\n')
>>> e.source, e.want >>> e.source, e.want
('print 1\n', '1\n') ('print(1)\n', '1\n')
>>> e = doctest.Example('print 1', '1') >>> e = doctest.Example('print(1)', '1')
>>> e.source, e.want >>> e.source, e.want
('print 1\n', '1\n') ('print(1)\n', '1\n')
>>> e = doctest.Example('print', '') >>> e = doctest.Example('print', '')
>>> e.source, e.want >>> e.source, e.want
...@@ -265,12 +265,12 @@ filename, and line number). The docstring is parsed by the `DocTest` ...@@ -265,12 +265,12 @@ filename, and line number). The docstring is parsed by the `DocTest`
constructor: constructor:
>>> docstring = ''' >>> docstring = '''
... >>> print 12 ... >>> print(12)
... 12 ... 12
... ...
... Non-example text. ... Non-example text.
... ...
... >>> print 'another\example' ... >>> print('another\example')
... another ... another
... example ... example
... ''' ... '''
...@@ -284,9 +284,9 @@ constructor: ...@@ -284,9 +284,9 @@ constructor:
2 2
>>> e1, e2 = test.examples >>> e1, e2 = test.examples
>>> (e1.source, e1.want, e1.lineno) >>> (e1.source, e1.want, e1.lineno)
('print 12\n', '12\n', 1) ('print(12)\n', '12\n', 1)
>>> (e2.source, e2.want, e2.lineno) >>> (e2.source, e2.want, e2.lineno)
("print 'another\\example'\n", 'another\nexample\n', 6) ("print('another\\example')\n", 'another\nexample\n', 6)
Source information (name, filename, and line number) is available as Source information (name, filename, and line number) is available as
attributes on the doctest object: attributes on the doctest object:
...@@ -307,7 +307,7 @@ If the docstring contains inconsistant leading whitespace in the ...@@ -307,7 +307,7 @@ If the docstring contains inconsistant leading whitespace in the
expected output of an example, then `DocTest` will raise a ValueError: expected output of an example, then `DocTest` will raise a ValueError:
>>> docstring = r''' >>> docstring = r'''
... >>> print 'bad\nindentation' ... >>> print('bad\nindentation')
... bad ... bad
... indentation ... indentation
... ''' ... '''
...@@ -319,8 +319,8 @@ If the docstring contains inconsistent leading whitespace on ...@@ -319,8 +319,8 @@ If the docstring contains inconsistent leading whitespace on
continuation lines, then `DocTest` will raise a ValueError: continuation lines, then `DocTest` will raise a ValueError:
>>> docstring = r''' >>> docstring = r'''
... >>> print ('bad indentation', ... >>> print(('bad indentation',
... ... 2) ... ... 2))
... ('bad', 'indentation') ... ('bad', 'indentation')
... ''' ... '''
>>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
...@@ -330,18 +330,18 @@ continuation lines, then `DocTest` will raise a ValueError: ...@@ -330,18 +330,18 @@ continuation lines, then `DocTest` will raise a ValueError:
If there's no blank space after a PS1 prompt ('>>>'), then `DocTest` If there's no blank space after a PS1 prompt ('>>>'), then `DocTest`
will raise a ValueError: will raise a ValueError:
>>> docstring = '>>>print 1\n1' >>> docstring = '>>>print(1)\n1'
>>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last): Traceback (most recent call last):
ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1' ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print(1)'
If there's no blank space after a PS2 prompt ('...'), then `DocTest` If there's no blank space after a PS2 prompt ('...'), then `DocTest`
will raise a ValueError: will raise a ValueError:
>>> docstring = '>>> if 1:\n...print 1\n1' >>> docstring = '>>> if 1:\n...print(1)\n1'
>>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last): Traceback (most recent call last):
ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1' ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print(1)'
""" """
...@@ -382,7 +382,7 @@ leading path components. ...@@ -382,7 +382,7 @@ leading path components.
>>> e = tests[0].examples[0] >>> e = tests[0].examples[0]
>>> (e.source, e.want, e.lineno) >>> (e.source, e.want, e.lineno)
('print sample_func(22)\n', '44\n', 3) ('print(sample_func(22))\n', '44\n', 3)
By default, tests are created for objects with no docstring: By default, tests are created for objects with no docstring:
...@@ -452,7 +452,7 @@ functions, classes, and the `__test__` dictionary, if it exists: ...@@ -452,7 +452,7 @@ functions, classes, and the `__test__` dictionary, if it exists:
>>> m = new.module('some_module') >>> m = new.module('some_module')
>>> def triple(val): >>> def triple(val):
... ''' ... '''
... >>> print triple(11) ... >>> print(triple(11))
... 33 ... 33
... ''' ... '''
... return val*3 ... return val*3
...@@ -461,11 +461,11 @@ functions, classes, and the `__test__` dictionary, if it exists: ...@@ -461,11 +461,11 @@ functions, classes, and the `__test__` dictionary, if it exists:
... 'SampleClass': SampleClass, ... 'SampleClass': SampleClass,
... '__doc__': ''' ... '__doc__': '''
... Module docstring. ... Module docstring.
... >>> print 'module' ... >>> print('module')
... module ... module
... ''', ... ''',
... '__test__': { ... '__test__': {
... 'd': '>>> print 6\n6\n>>> print 7\n7\n', ... 'd': '>>> print(6)\n6\n>>> print(7)\n7\n',
... 'c': triple}}) ... 'c': triple}})
>>> finder = doctest.DocTestFinder() >>> finder = doctest.DocTestFinder()
...@@ -570,7 +570,7 @@ DocTestFinder finds the line number of each example: ...@@ -570,7 +570,7 @@ DocTestFinder finds the line number of each example:
... ... ... ...
... ...
... >>> for x in range(10): ... >>> for x in range(10):
... ... print x, ... ... print(x, end=' ')
... 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
...@@ -591,8 +591,8 @@ text: ...@@ -591,8 +591,8 @@ text:
>>> s = ''' >>> s = '''
... >>> x, y = 2, 3 # no output expected ... >>> x, y = 2, 3 # no output expected
... >>> if 1: ... >>> if 1:
... ... print x ... ... print(x)
... ... print y ... ... print(y)
... 2 ... 2
... 3 ... 3
... ...
...@@ -609,7 +609,7 @@ text: ...@@ -609,7 +609,7 @@ text:
Text: '\n' Text: '\n'
Example: ('x, y = 2, 3 # no output expected\n', '', 1) Example: ('x, y = 2, 3 # no output expected\n', '', 1)
Text: '' Text: ''
Example: ('if 1:\n print x\n print y\n', '2\n3\n', 2) Example: ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2)
Text: '\nSome text.\n' Text: '\nSome text.\n'
Example: ('x+y\n', '5\n', 9) Example: ('x+y\n', '5\n', 9)
Text: '' Text: ''
...@@ -619,7 +619,7 @@ The `get_examples` method returns just the examples: ...@@ -619,7 +619,7 @@ The `get_examples` method returns just the examples:
>>> for piece in parser.get_examples(s): >>> for piece in parser.get_examples(s):
... print((piece.source, piece.want, piece.lineno)) ... print((piece.source, piece.want, piece.lineno))
('x, y = 2, 3 # no output expected\n', '', 1) ('x, y = 2, 3 # no output expected\n', '', 1)
('if 1:\n print x\n print y\n', '2\n3\n', 2) ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2)
('x+y\n', '5\n', 9) ('x+y\n', '5\n', 9)
The `get_doctest` method creates a Test from the examples, along with the The `get_doctest` method creates a Test from the examples, along with the
...@@ -631,7 +631,7 @@ given arguments: ...@@ -631,7 +631,7 @@ given arguments:
>>> for piece in test.examples: >>> for piece in test.examples:
... print((piece.source, piece.want, piece.lineno)) ... print((piece.source, piece.want, piece.lineno))
('x, y = 2, 3 # no output expected\n', '', 1) ('x, y = 2, 3 # no output expected\n', '', 1)
('if 1:\n print x\n print y\n', '2\n3\n', 2) ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2)
('x+y\n', '5\n', 9) ('x+y\n', '5\n', 9)
""" """
...@@ -645,7 +645,7 @@ statistics. Here's a simple DocTest case we can use: ...@@ -645,7 +645,7 @@ statistics. Here's a simple DocTest case we can use:
>>> def f(x): >>> def f(x):
... ''' ... '''
... >>> x = 12 ... >>> x = 12
... >>> print x ... >>> print(x)
... 12 ... 12
... >>> x//2 ... >>> x//2
... 6 ... 6
...@@ -666,7 +666,7 @@ the failure and proceeds to the next example: ...@@ -666,7 +666,7 @@ the failure and proceeds to the next example:
>>> def f(x): >>> def f(x):
... ''' ... '''
... >>> x = 12 ... >>> x = 12
... >>> print x ... >>> print(x)
... 14 ... 14
... >>> x//2 ... >>> x//2
... 6 ... 6
...@@ -679,13 +679,13 @@ the failure and proceeds to the next example: ...@@ -679,13 +679,13 @@ the failure and proceeds to the next example:
Expecting nothing Expecting nothing
ok ok
Trying: Trying:
print x print(x)
Expecting: Expecting:
14 14
********************************************************************** **********************************************************************
File ..., line 4, in f File ..., line 4, in f
Failed example: Failed example:
print x print(x)
Expected: Expected:
14 14
Got: Got:
...@@ -704,7 +704,7 @@ output: ...@@ -704,7 +704,7 @@ output:
>>> def f(x): >>> def f(x):
... ''' ... '''
... >>> x = 12 ... >>> x = 12
... >>> print x ... >>> print(x)
... 12 ... 12
... >>> x//2 ... >>> x//2
... 6 ... 6
...@@ -717,7 +717,7 @@ output: ...@@ -717,7 +717,7 @@ output:
Expecting nothing Expecting nothing
ok ok
Trying: Trying:
print x print(x)
Expecting: Expecting:
12 12
ok ok
...@@ -747,7 +747,7 @@ iff `-v` appears in sys.argv: ...@@ -747,7 +747,7 @@ iff `-v` appears in sys.argv:
Expecting nothing Expecting nothing
ok ok
Trying: Trying:
print x print(x)
Expecting: Expecting:
12 12
ok ok
...@@ -774,7 +774,7 @@ replaced with any other string: ...@@ -774,7 +774,7 @@ replaced with any other string:
>>> def f(x): >>> def f(x):
... ''' ... '''
... >>> 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: integer division or modulo by zero
... ''' ... '''
...@@ -790,7 +790,7 @@ unexpected exception: ...@@ -790,7 +790,7 @@ unexpected exception:
>>> def f(x): >>> def f(x):
... ''' ... '''
... >>> x = 12 ... >>> x = 12
... >>> 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: integer division or modulo by zero
...@@ -801,7 +801,7 @@ unexpected exception: ...@@ -801,7 +801,7 @@ unexpected exception:
********************************************************************** **********************************************************************
File ..., line 4, in f File ..., line 4, in f
Failed example: Failed example:
print 'pre-exception output', x//0 print('pre-exception output', x//0)
Exception raised: Exception raised:
... ...
ZeroDivisionError: integer division or modulo by zero ZeroDivisionError: integer division or modulo by zero
...@@ -942,7 +942,7 @@ The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines ...@@ -942,7 +942,7 @@ The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines
and the '<BLANKLINE>' marker: and the '<BLANKLINE>' marker:
>>> def f(x): >>> def f(x):
... '>>> print "a\\n\\nb"\na\n<BLANKLINE>\nb\n' ... '>>> print("a\\n\\nb")\na\n<BLANKLINE>\nb\n'
>>> # Without the flag: >>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -957,7 +957,7 @@ and the '<BLANKLINE>' marker: ...@@ -957,7 +957,7 @@ and the '<BLANKLINE>' marker:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print "a\n\nb" print("a\n\nb")
Expected: Expected:
a a
<BLANKLINE> <BLANKLINE>
...@@ -972,7 +972,7 @@ The NORMALIZE_WHITESPACE flag causes all sequences of whitespace to be ...@@ -972,7 +972,7 @@ The NORMALIZE_WHITESPACE flag causes all sequences of whitespace to be
treated as equal: treated as equal:
>>> def f(x): >>> def f(x):
... '>>> print 1, 2, 3\n 1 2\n 3' ... '>>> print(1, 2, 3)\n 1 2\n 3'
>>> # Without the flag: >>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -981,7 +981,7 @@ treated as equal: ...@@ -981,7 +981,7 @@ treated as equal:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print 1, 2, 3 print(1, 2, 3)
Expected: Expected:
1 2 1 2
3 3
...@@ -1004,7 +1004,7 @@ The ELLIPSIS flag causes ellipsis marker ("...") in the expected ...@@ -1004,7 +1004,7 @@ The ELLIPSIS flag causes ellipsis marker ("...") in the expected
output to match any substring in the actual output: output to match any substring in the actual output:
>>> def f(x): >>> def f(x):
... '>>> print range(15)\n[0, 1, 2, ..., 14]\n' ... '>>> print(range(15))\n[0, 1, 2, ..., 14]\n'
>>> # Without the flag: >>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1013,7 +1013,7 @@ output to match any substring in the actual output: ...@@ -1013,7 +1013,7 @@ output to match any substring in the actual output:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(15) print(range(15))
Expected: Expected:
[0, 1, 2, ..., 14] [0, 1, 2, ..., 14]
Got: Got:
...@@ -1071,7 +1071,7 @@ and actual outputs to be displayed using a unified diff: ...@@ -1071,7 +1071,7 @@ and actual outputs to be displayed using a unified diff:
>>> def f(x): >>> def f(x):
... r''' ... r'''
... >>> print '\n'.join('abcdefg') ... >>> print('\n'.join('abcdefg'))
... a ... a
... B ... B
... c ... c
...@@ -1088,7 +1088,7 @@ and actual outputs to be displayed using a unified diff: ...@@ -1088,7 +1088,7 @@ and actual outputs to be displayed using a unified diff:
********************************************************************** **********************************************************************
File ..., line 3, in f File ..., line 3, in f
Failed example: Failed example:
print '\n'.join('abcdefg') print('\n'.join('abcdefg'))
Expected: Expected:
a a
B B
...@@ -1115,7 +1115,7 @@ and actual outputs to be displayed using a unified diff: ...@@ -1115,7 +1115,7 @@ and actual outputs to be displayed using a unified diff:
********************************************************************** **********************************************************************
File ..., line 3, in f File ..., line 3, in f
Failed example: Failed example:
print '\n'.join('abcdefg') print('\n'.join('abcdefg'))
Differences (unified diff with -expected +actual): Differences (unified diff with -expected +actual):
@@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
a a
...@@ -1140,7 +1140,7 @@ and actual outputs to be displayed using a context diff: ...@@ -1140,7 +1140,7 @@ and actual outputs to be displayed using a context diff:
********************************************************************** **********************************************************************
File ..., line 3, in f File ..., line 3, in f
Failed example: Failed example:
print '\n'.join('abcdefg') print('\n'.join('abcdefg'))
Differences (context diff with expected followed by actual): Differences (context diff with expected followed by actual):
*************** ***************
*** 1,7 **** *** 1,7 ****
...@@ -1168,7 +1168,7 @@ marking, as well as interline differences. ...@@ -1168,7 +1168,7 @@ marking, as well as interline differences.
>>> def f(x): >>> def f(x):
... r''' ... r'''
... >>> print "a b c d e f g h i j k l m" ... >>> print("a b c d e f g h i j k l m")
... a b c d e f g h i j k 1 m ... a b c d e f g h i j k 1 m
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1178,7 +1178,7 @@ marking, as well as interline differences. ...@@ -1178,7 +1178,7 @@ marking, as well as interline differences.
********************************************************************** **********************************************************************
File ..., line 3, in f File ..., line 3, in f
Failed example: Failed example:
print "a b c d e f g h i j k l m" print("a b c d e f g h i j k l m")
Differences (ndiff with -expected +actual): Differences (ndiff with -expected +actual):
- a b c d e f g h i j k 1 m - a b c d e f g h i j k 1 m
? ^ ? ^
...@@ -1191,15 +1191,15 @@ failing example: ...@@ -1191,15 +1191,15 @@ failing example:
>>> def f(x): >>> def f(x):
... r''' ... r'''
... >>> print 1 # first success ... >>> print(1) # first success
... 1 ... 1
... >>> print 2 # first failure ... >>> print(2) # first failure
... 200 ... 200
... >>> print 3 # second failure ... >>> print(3) # second failure
... 300 ... 300
... >>> print 4 # second success ... >>> print(4) # second success
... 4 ... 4
... >>> print 5 # third failure ... >>> print(5) # third failure
... 500 ... 500
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1209,7 +1209,7 @@ failing example: ...@@ -1209,7 +1209,7 @@ failing example:
********************************************************************** **********************************************************************
File ..., line 5, in f File ..., line 5, in f
Failed example: Failed example:
print 2 # first failure print(2) # first failure
Expected: Expected:
200 200
Got: Got:
...@@ -1221,18 +1221,18 @@ However, output from `report_start` is not supressed: ...@@ -1221,18 +1221,18 @@ However, output from `report_start` is not supressed:
>>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test)
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
Trying: Trying:
print 1 # first success print(1) # first success
Expecting: Expecting:
1 1
ok ok
Trying: Trying:
print 2 # first failure print(2) # first failure
Expecting: Expecting:
200 200
********************************************************************** **********************************************************************
File ..., line 5, in f File ..., line 5, in f
Failed example: Failed example:
print 2 # first failure print(2) # first failure
Expected: Expected:
200 200
Got: Got:
...@@ -1244,15 +1244,15 @@ count as failures: ...@@ -1244,15 +1244,15 @@ count as failures:
>>> def f(x): >>> def f(x):
... r''' ... r'''
... >>> print 1 # first success ... >>> print(1) # first success
... 1 ... 1
... >>> raise ValueError(2) # first failure ... >>> raise ValueError(2) # first failure
... 200 ... 200
... >>> print 3 # second failure ... >>> print(3) # second failure
... 300 ... 300
... >>> print 4 # second success ... >>> print(4) # second success
... 4 ... 4
... >>> print 5 # third failure ... >>> print(5) # third failure
... 500 ... 500
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1298,10 +1298,10 @@ single example. To turn an option on for an example, follow that ...@@ -1298,10 +1298,10 @@ single example. To turn an option on for an example, follow that
example with a comment of the form ``# doctest: +OPTION``: example with a comment of the form ``# doctest: +OPTION``:
>>> def f(x): r''' >>> def f(x): r'''
... >>> print range(10) # should fail: no ellipsis ... >>> print(range(10)) # should fail: no ellipsis
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ...
... >>> print range(10) # doctest: +ELLIPSIS ... >>> print(range(10)) # doctest: +ELLIPSIS
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1310,7 +1310,7 @@ example with a comment of the form ``# doctest: +OPTION``: ...@@ -1310,7 +1310,7 @@ example with a comment of the form ``# doctest: +OPTION``:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # should fail: no ellipsis print(range(10)) # should fail: no ellipsis
Expected: Expected:
[0, 1, ..., 9] [0, 1, ..., 9]
Got: Got:
...@@ -1321,11 +1321,11 @@ To turn an option off for an example, follow that example with a ...@@ -1321,11 +1321,11 @@ To turn an option off for an example, follow that example with a
comment of the form ``# doctest: -OPTION``: comment of the form ``# doctest: -OPTION``:
>>> def f(x): r''' >>> def f(x): r'''
... >>> print range(10) ... >>> print(range(10))
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ...
... >>> # should fail: no ellipsis ... >>> # should fail: no ellipsis
... >>> print range(10) # doctest: -ELLIPSIS ... >>> print(range(10)) # doctest: -ELLIPSIS
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1335,7 +1335,7 @@ comment of the form ``# doctest: -OPTION``: ...@@ -1335,7 +1335,7 @@ comment of the form ``# doctest: -OPTION``:
********************************************************************** **********************************************************************
File ..., line 6, in f File ..., line 6, in f
Failed example: Failed example:
print range(10) # doctest: -ELLIPSIS print(range(10)) # doctest: -ELLIPSIS
Expected: Expected:
[0, 1, ..., 9] [0, 1, ..., 9]
Got: Got:
...@@ -1346,13 +1346,13 @@ Option directives affect only the example that they appear with; they ...@@ -1346,13 +1346,13 @@ Option directives affect only the example that they appear with; they
do not change the options for surrounding examples: do not change the options for surrounding examples:
>>> def f(x): r''' >>> def f(x): r'''
... >>> print range(10) # Should fail: no ellipsis ... >>> print(range(10)) # Should fail: no ellipsis
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ...
... >>> print range(10) # doctest: +ELLIPSIS ... >>> print(range(10)) # doctest: +ELLIPSIS
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ...
... >>> print range(10) # Should fail: no ellipsis ... >>> print(range(10)) # Should fail: no ellipsis
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1361,7 +1361,7 @@ do not change the options for surrounding examples: ...@@ -1361,7 +1361,7 @@ do not change the options for surrounding examples:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail: no ellipsis print(range(10)) # Should fail: no ellipsis
Expected: Expected:
[0, 1, ..., 9] [0, 1, ..., 9]
Got: Got:
...@@ -1369,7 +1369,7 @@ do not change the options for surrounding examples: ...@@ -1369,7 +1369,7 @@ do not change the options for surrounding examples:
********************************************************************** **********************************************************************
File ..., line 8, in f File ..., line 8, in f
Failed example: Failed example:
print range(10) # Should fail: no ellipsis print(range(10)) # Should fail: no ellipsis
Expected: Expected:
[0, 1, ..., 9] [0, 1, ..., 9]
Got: Got:
...@@ -1380,9 +1380,9 @@ Multiple options may be modified by a single option directive. They ...@@ -1380,9 +1380,9 @@ Multiple options may be modified by a single option directive. They
may be separated by whitespace, commas, or both: may be separated by whitespace, commas, or both:
>>> def f(x): r''' >>> def f(x): r'''
... >>> print range(10) # Should fail ... >>> print(range(10)) # Should fail
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... >>> print range(10) # Should succeed ... >>> print(range(10)) # Should succeed
... ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE ... ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ''' ... '''
...@@ -1392,7 +1392,7 @@ may be separated by whitespace, commas, or both: ...@@ -1392,7 +1392,7 @@ may be separated by whitespace, commas, or both:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail print(range(10)) # Should fail
Expected: Expected:
[0, 1, ..., 9] [0, 1, ..., 9]
Got: Got:
...@@ -1400,9 +1400,9 @@ may be separated by whitespace, commas, or both: ...@@ -1400,9 +1400,9 @@ may be separated by whitespace, commas, or both:
(1, 2) (1, 2)
>>> def f(x): r''' >>> def f(x): r'''
... >>> print range(10) # Should fail ... >>> print(range(10)) # Should fail
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... >>> print range(10) # Should succeed ... >>> print(range(10)) # Should succeed
... ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE ... ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ''' ... '''
...@@ -1412,7 +1412,7 @@ may be separated by whitespace, commas, or both: ...@@ -1412,7 +1412,7 @@ may be separated by whitespace, commas, or both:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail print(range(10)) # Should fail
Expected: Expected:
[0, 1, ..., 9] [0, 1, ..., 9]
Got: Got:
...@@ -1420,9 +1420,9 @@ may be separated by whitespace, commas, or both: ...@@ -1420,9 +1420,9 @@ may be separated by whitespace, commas, or both:
(1, 2) (1, 2)
>>> def f(x): r''' >>> def f(x): r'''
... >>> print range(10) # Should fail ... >>> print(range(10)) # Should fail
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... >>> print range(10) # Should succeed ... >>> print(range(10)) # Should succeed
... ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE ... ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ''' ... '''
...@@ -1432,7 +1432,7 @@ may be separated by whitespace, commas, or both: ...@@ -1432,7 +1432,7 @@ may be separated by whitespace, commas, or both:
********************************************************************** **********************************************************************
File ..., line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail print(range(10)) # Should fail
Expected: Expected:
[0, 1, ..., 9] [0, 1, ..., 9]
Got: Got:
...@@ -1443,7 +1443,7 @@ The option directive may be put on the line following the source, as ...@@ -1443,7 +1443,7 @@ The option directive may be put on the line following the source, as
long as a continuation prompt is used: long as a continuation prompt is used:
>>> def f(x): r''' >>> def f(x): r'''
... >>> print range(10) ... >>> print(range(10))
... ... # doctest: +ELLIPSIS ... ... # doctest: +ELLIPSIS
... [0, 1, ..., 9] ... [0, 1, ..., 9]
... ''' ... '''
...@@ -1456,11 +1456,11 @@ at the end of any line: ...@@ -1456,11 +1456,11 @@ at the end of any line:
>>> def f(x): r''' >>> def f(x): r'''
... >>> for x in range(10): # doctest: +ELLIPSIS ... >>> for x in range(10): # doctest: +ELLIPSIS
... ... print x, ... ... print(x, end=' ')
... 0 1 2 ... 9 ... 0 1 2 ... 9
... ...
... >>> for x in range(10): ... >>> for x in range(10):
... ... print x, # doctest: +ELLIPSIS ... ... print(x, end=' ') # doctest: +ELLIPSIS
... 0 1 2 ... 9 ... 0 1 2 ... 9
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1473,7 +1473,7 @@ option directive, then they are combined: ...@@ -1473,7 +1473,7 @@ option directive, then they are combined:
>>> def f(x): r''' >>> def f(x): r'''
... Should fail (option directive not on the last line): ... Should fail (option directive not on the last line):
... >>> for x in range(10): # doctest: +ELLIPSIS ... >>> for x in range(10): # doctest: +ELLIPSIS
... ... print x, # doctest: +NORMALIZE_WHITESPACE ... ... print(x, end=' ') # doctest: +NORMALIZE_WHITESPACE
... 0 1 2...9 ... 0 1 2...9
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
...@@ -1486,13 +1486,13 @@ It is an error to have a comment of the form ``# doctest:`` that is ...@@ -1486,13 +1486,13 @@ It is an error to have a comment of the form ``# doctest:`` that is
`register_option`: `register_option`:
>>> # Error: Option not registered >>> # Error: Option not registered
>>> s = '>>> print 12 #doctest: +BADOPTION' >>> s = '>>> print(12) #doctest: +BADOPTION'
>>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0)
Traceback (most recent call last): Traceback (most recent call last):
ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION' ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION'
>>> # Error: No + or - prefix >>> # Error: No + or - prefix
>>> s = '>>> print 12 #doctest: ELLIPSIS' >>> s = '>>> print(12) #doctest: ELLIPSIS'
>>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0)
Traceback (most recent call last): Traceback (most recent call last):
ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS' ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS'
...@@ -1519,7 +1519,7 @@ words and expected output are converted to comments: ...@@ -1519,7 +1519,7 @@ words and expected output are converted to comments:
>>> print(doctest.testsource(test.test_doctest, name)) >>> print(doctest.testsource(test.test_doctest, name))
# Blah blah # Blah blah
# #
print sample_func(22) print(sample_func(22))
# Expected: # Expected:
## 44 ## 44
# #
...@@ -1528,7 +1528,7 @@ words and expected output are converted to comments: ...@@ -1528,7 +1528,7 @@ words and expected output are converted to comments:
>>> name = 'test.test_doctest.SampleNewStyleClass' >>> name = 'test.test_doctest.SampleNewStyleClass'
>>> print(doctest.testsource(test.test_doctest, name)) >>> print(doctest.testsource(test.test_doctest, name))
print '1\n2\n3' print('1\n2\n3')
# Expected: # Expected:
## 1 ## 1
## 2 ## 2
...@@ -1537,10 +1537,10 @@ words and expected output are converted to comments: ...@@ -1537,10 +1537,10 @@ words and expected output are converted to comments:
>>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> name = 'test.test_doctest.SampleClass.a_classmethod'
>>> print(doctest.testsource(test.test_doctest, name)) >>> print(doctest.testsource(test.test_doctest, name))
print SampleClass.a_classmethod(10) print(SampleClass.a_classmethod(10))
# Expected: # Expected:
## 12 ## 12
print SampleClass(0).a_classmethod(10) print(SampleClass(0).a_classmethod(10))
# Expected: # Expected:
## 12 ## 12
<BLANKLINE> <BLANKLINE>
...@@ -1552,7 +1552,7 @@ Create a docstring that we want to debug: ...@@ -1552,7 +1552,7 @@ Create a docstring that we want to debug:
>>> s = ''' >>> s = '''
... >>> x = 12 ... >>> x = 12
... >>> print x ... >>> print(x)
... 12 ... 12
... ''' ... '''
...@@ -1560,7 +1560,7 @@ Create some fake stdin input, to feed to the debugger: ...@@ -1560,7 +1560,7 @@ Create some fake stdin input, to feed to the debugger:
>>> import tempfile >>> import tempfile
>>> real_stdin = sys.stdin >>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput(['next', 'print x', 'continue']) >>> sys.stdin = _FakeInput(['next', 'print(x)', 'continue'])
Run the debugger on the docstring, and then restore sys.stdin. Run the debugger on the docstring, and then restore sys.stdin.
...@@ -1571,7 +1571,7 @@ Run the debugger on the docstring, and then restore sys.stdin. ...@@ -1571,7 +1571,7 @@ Run the debugger on the docstring, and then restore sys.stdin.
12 12
--Return-- --Return--
> <string>(1)<module>()->None > <string>(1)<module>()->None
(Pdb) print x (Pdb) print(x)
12 12
(Pdb) continue (Pdb) continue
...@@ -1601,7 +1601,7 @@ def test_pdb_set_trace(): ...@@ -1601,7 +1601,7 @@ def test_pdb_set_trace():
>>> import tempfile >>> import tempfile
>>> real_stdin = sys.stdin >>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([ >>> sys.stdin = _FakeInput([
... 'print x', # print data defined by the example ... 'print(x)', # print data defined by the example
... 'continue', # stop debugging ... 'continue', # stop debugging
... '']) ... ''])
...@@ -1610,7 +1610,7 @@ def test_pdb_set_trace(): ...@@ -1610,7 +1610,7 @@ def test_pdb_set_trace():
--Return-- --Return--
> <doctest foo[1]>(1)<module>()->None > <doctest foo[1]>(1)<module>()->None
-> import pdb; pdb.set_trace() -> import pdb; pdb.set_trace()
(Pdb) print x (Pdb) print(x)
42 42
(Pdb) continue (Pdb) continue
(0, 2) (0, 2)
...@@ -1628,9 +1628,9 @@ def test_pdb_set_trace(): ...@@ -1628,9 +1628,9 @@ def test_pdb_set_trace():
>>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
>>> real_stdin = sys.stdin >>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([ >>> sys.stdin = _FakeInput([
... 'print y', # print data defined in the function ... 'print(y)', # print data defined in the function
... 'up', # out of function ... 'up', # out of function
... 'print x', # print data defined by the example ... 'print(x)', # print data defined by the example
... 'continue', # stop debugging ... 'continue', # stop debugging
... '']) ... ''])
...@@ -1641,12 +1641,12 @@ def test_pdb_set_trace(): ...@@ -1641,12 +1641,12 @@ def test_pdb_set_trace():
--Return-- --Return--
> <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None > <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None
-> import pdb; pdb.set_trace() -> import pdb; pdb.set_trace()
(Pdb) print y (Pdb) print(y)
2 2
(Pdb) up (Pdb) up
> <doctest foo[1]>(1)<module>() > <doctest foo[1]>(1)<module>()
-> calls_set_trace() -> calls_set_trace()
(Pdb) print x (Pdb) print(x)
1 1
(Pdb) continue (Pdb) continue
(0, 2) (0, 2)
...@@ -1658,7 +1658,7 @@ def test_pdb_set_trace(): ...@@ -1658,7 +1658,7 @@ def test_pdb_set_trace():
... >>> def f(x): ... >>> def f(x):
... ... g(x*2) ... ... g(x*2)
... >>> def g(x): ... >>> def g(x):
... ... print x+3 ... ... print(x+3)
... ... import pdb; pdb.set_trace() ... ... import pdb; pdb.set_trace()
... >>> f(3) ... >>> f(3)
... ''' ... '''
...@@ -1680,7 +1680,7 @@ def test_pdb_set_trace(): ...@@ -1680,7 +1680,7 @@ def test_pdb_set_trace():
-> import pdb; pdb.set_trace() -> import pdb; pdb.set_trace()
(Pdb) list (Pdb) list
1 def g(x): 1 def g(x):
2 print x+3 2 print(x+3)
3 -> import pdb; pdb.set_trace() 3 -> import pdb; pdb.set_trace()
[EOF] [EOF]
(Pdb) next (Pdb) next
...@@ -1737,11 +1737,11 @@ def test_pdb_set_trace_nested(): ...@@ -1737,11 +1737,11 @@ def test_pdb_set_trace_nested():
>>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
>>> real_stdin = sys.stdin >>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([ >>> sys.stdin = _FakeInput([
... 'print y', # print data defined in the function ... 'print(y)', # print data defined in the function
... 'step', 'step', 'step', 'step', 'step', 'step', 'print z', ... 'step', 'step', 'step', 'step', 'step', 'step', 'print(z)',
... 'up', 'print x', ... 'up', 'print(x)',
... 'up', 'print y', ... 'up', 'print(y)',
... 'up', 'print foo', ... 'up', 'print(foo)',
... 'continue', # stop debugging ... 'continue', # stop debugging
... '']) ... ''])
...@@ -1751,7 +1751,7 @@ def test_pdb_set_trace_nested(): ...@@ -1751,7 +1751,7 @@ def test_pdb_set_trace_nested():
... sys.stdin = real_stdin ... sys.stdin = real_stdin
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace() > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
-> self.f1() -> self.f1()
(Pdb) print y (Pdb) print(y)
1 1
(Pdb) step (Pdb) step
--Call-- --Call--
...@@ -1773,22 +1773,22 @@ def test_pdb_set_trace_nested(): ...@@ -1773,22 +1773,22 @@ def test_pdb_set_trace_nested():
(Pdb) step (Pdb) step
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(13)f2() > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(13)f2()
-> z = 2 -> z = 2
(Pdb) print z (Pdb) print(z)
1 1
(Pdb) up (Pdb) up
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1() > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1()
-> self.f2() -> self.f2()
(Pdb) print x (Pdb) print(x)
1 1
(Pdb) up (Pdb) up
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace() > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
-> self.f1() -> self.f1()
(Pdb) print y (Pdb) print(y)
1 1
(Pdb) up (Pdb) up
> <doctest foo[1]>(1)<module>() > <doctest foo[1]>(1)<module>()
-> calls_set_trace() -> calls_set_trace()
(Pdb) print foo (Pdb) print(foo)
*** NameError: name 'foo' is not defined *** NameError: name 'foo' is not defined
(Pdb) continue (Pdb) continue
(0, 2) (0, 2)
...@@ -2099,9 +2099,9 @@ def test_unittest_reportflags(): ...@@ -2099,9 +2099,9 @@ def test_unittest_reportflags():
... ...
Failed example: Failed example:
if 1: if 1:
print 'a' print('a')
print print()
print 'b' print('b')
Differences (ndiff with -expected +actual): Differences (ndiff with -expected +actual):
a a
- <BLANKLINE> - <BLANKLINE>
...@@ -2185,9 +2185,9 @@ Verbosity can be increased with the optional `verbose` paremter: ...@@ -2185,9 +2185,9 @@ Verbosity can be increased with the optional `verbose` paremter:
ok ok
Trying: Trying:
if 1: if 1:
print 'a' print('a')
print print()
print 'b' print('b')
Expecting: Expecting:
a a
<BLANKLINE> <BLANKLINE>
...@@ -2279,19 +2279,19 @@ def old_test1(): r""" ...@@ -2279,19 +2279,19 @@ def old_test1(): r"""
>>> t = Tester(globs={'x': 42}, verbose=0) >>> t = Tester(globs={'x': 42}, verbose=0)
>>> t.runstring(r''' >>> t.runstring(r'''
... >>> x = x * 2 ... >>> x = x * 2
... >>> print x ... >>> print(x)
... 42 ... 42
... ''', 'XYZ') ... ''', 'XYZ')
********************************************************************** **********************************************************************
Line 3, in XYZ Line 3, in XYZ
Failed example: Failed example:
print x print(x)
Expected: Expected:
42 42
Got: Got:
84 84
(1, 2) (1, 2)
>>> t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2') >>> t.runstring(">>> x = x * 2\n>>> print(x)\n84\n", 'example2')
(0, 2) (0, 2)
>>> t.summarize() >>> t.summarize()
********************************************************************** **********************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment