[Python-3000-checkins] r53714 - python/branches/p3yk/Lib/test/test_doctest.py

guido.van.rossum python-3000-checkins at python.org
Fri Feb 9 23:43:47 CET 2007


Author: guido.van.rossum
Date: Fri Feb  9 23:43:47 2007
New Revision: 53714

Modified:
   python/branches/p3yk/Lib/test/test_doctest.py
Log:
Redue the failure rate to 13 tests.  Bah.


Modified: python/branches/p3yk/Lib/test/test_doctest.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_doctest.py	(original)
+++ python/branches/p3yk/Lib/test/test_doctest.py	Fri Feb  9 23:43:47 2007
@@ -35,7 +35,7 @@
     >>> for i in range(10):
     ...     sc = sc.double()
     ...     print(sc.get(), end=' ')
-    6 12 24 48 96 192 384 768 1536 3072
+    6 12 24 48 96 192 384 768 1536 3072 
     """
     def __init__(self, val):
         """
@@ -166,10 +166,10 @@
 These attributes are set by the constructor.  `source` and `want` are
 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.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
 specified positionally; the remaining arguments should be specified as
@@ -186,22 +186,22 @@
 The constructor normalizes the `source` string to end in a 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
-    ('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
-    ('print 1\n', '1\n')
+    ('print(1)\n', '1\n')
 
     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
-    ('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
-    ('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)
     >>> e = doctest.Example('', '')
@@ -211,13 +211,13 @@
 The constructor normalizes the `want` string to end in a newline,
 unless it's the empty string:
 
-    >>> e = doctest.Example('print 1', '1\n')
+    >>> e = doctest.Example('print(1)', '1\n')
     >>> 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
-    ('print 1\n', '1\n')
+    ('print(1)\n', '1\n')
 
     >>> e = doctest.Example('print', '')
     >>> e.source, e.want
@@ -265,12 +265,12 @@
 constructor:
 
     >>> docstring = '''
-    ...     >>> print 12
+    ...     >>> print(12)
     ...     12
     ...
     ... Non-example text.
     ...
-    ...     >>> print 'another\example'
+    ...     >>> print('another\example')
     ...     another
     ...     example
     ... '''
@@ -284,9 +284,9 @@
     2
     >>> e1, e2 = test.examples
     >>> (e1.source, e1.want, e1.lineno)
-    ('print 12\n', '12\n', 1)
+    ('print(12)\n', '12\n', 1)
     >>> (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
 attributes on the doctest object:
@@ -307,7 +307,7 @@
 expected output of an example, then `DocTest` will raise a ValueError:
 
     >>> docstring = r'''
-    ...       >>> print 'bad\nindentation'
+    ...       >>> print('bad\nindentation')
     ...       bad
     ...     indentation
     ...     '''
@@ -319,8 +319,8 @@
 continuation lines, then `DocTest` will raise a ValueError:
 
     >>> docstring = r'''
-    ...       >>> print ('bad indentation',
-    ...     ...          2)
+    ...       >>> print(('bad indentation',
+    ...     ...          2))
     ...       ('bad', 'indentation')
     ...     '''
     >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
@@ -330,18 +330,18 @@
 If there's no blank space after a PS1 prompt ('>>>'), then `DocTest`
 will raise a ValueError:
 
-    >>> docstring = '>>>print 1\n1'
+    >>> docstring = '>>>print(1)\n1'
     >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
     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`
 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)
     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 @@
 
     >>> e = tests[0].examples[0]
     >>> (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:
 
@@ -452,7 +452,7 @@
     >>> m = new.module('some_module')
     >>> def triple(val):
     ...     '''
-    ...     >>> print triple(11)
+    ...     >>> print(triple(11))
     ...     33
     ...     '''
     ...     return val*3
@@ -461,11 +461,11 @@
     ...     'SampleClass': SampleClass,
     ...     '__doc__': '''
     ...         Module docstring.
-    ...             >>> print 'module'
+    ...             >>> print('module')
     ...             module
     ...         ''',
     ...     '__test__': {
-    ...         'd': '>>> print 6\n6\n>>> print 7\n7\n',
+    ...         'd': '>>> print(6)\n6\n>>> print(7)\n7\n',
     ...         'c': triple}})
 
     >>> finder = doctest.DocTestFinder()
@@ -570,8 +570,8 @@
     ...     ...
     ...
     ...     >>> for x in range(10):
-    ...     ...     print x,
-    ...     0 1 2 3 4 5 6 7 8 9
+    ...     ...     print(x, end=' ')
+    ...     0 1 2 3 4 5 6 7 8 9 
     ...     >>> x//2
     ...     6
     ...     '''
@@ -591,8 +591,8 @@
     >>> s = '''
     ...     >>> x, y = 2, 3  # no output expected
     ...     >>> if 1:
-    ...     ...     print x
-    ...     ...     print y
+    ...     ...     print(x)
+    ...     ...     print(y)
     ...     2
     ...     3
     ...
@@ -609,7 +609,7 @@
        Text: '\n'
     Example: ('x, y = 2, 3  # no output expected\n', '', 1)
        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'
     Example: ('x+y\n', '5\n', 9)
        Text: ''
@@ -619,7 +619,7 @@
     >>> for piece in parser.get_examples(s):
     ...     print((piece.source, piece.want, piece.lineno))
     ('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)
 
 The `get_doctest` method creates a Test from the examples, along with the
@@ -631,7 +631,7 @@
     >>> for piece in test.examples:
     ...     print((piece.source, piece.want, piece.lineno))
     ('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)
 """
 
@@ -645,7 +645,7 @@
     >>> def f(x):
     ...     '''
     ...     >>> x = 12
-    ...     >>> print x
+    ...     >>> print(x)
     ...     12
     ...     >>> x//2
     ...     6
@@ -666,7 +666,7 @@
     >>> def f(x):
     ...     '''
     ...     >>> x = 12
-    ...     >>> print x
+    ...     >>> print(x)
     ...     14
     ...     >>> x//2
     ...     6
@@ -679,13 +679,13 @@
     Expecting nothing
     ok
     Trying:
-        print x
+        print(x)
     Expecting:
         14
     **********************************************************************
     File ..., line 4, in f
     Failed example:
-        print x
+        print(x)
     Expected:
         14
     Got:
@@ -704,7 +704,7 @@
     >>> def f(x):
     ...     '''
     ...     >>> x = 12
-    ...     >>> print x
+    ...     >>> print(x)
     ...     12
     ...     >>> x//2
     ...     6
@@ -717,7 +717,7 @@
     Expecting nothing
     ok
     Trying:
-        print x
+        print(x)
     Expecting:
         12
     ok
@@ -747,7 +747,7 @@
     Expecting nothing
     ok
     Trying:
-        print x
+        print(x)
     Expecting:
         12
     ok
@@ -774,7 +774,7 @@
     >>> def f(x):
     ...     '''
     ...     >>> x = 12
-    ...     >>> print x//0
+    ...     >>> print(x//0)
     ...     Traceback (most recent call last):
     ...     ZeroDivisionError: integer division or modulo by zero
     ...     '''
@@ -790,7 +790,7 @@
     >>> def f(x):
     ...     '''
     ...     >>> x = 12
-    ...     >>> print 'pre-exception output', x//0
+    ...     >>> print('pre-exception output', x//0)
     ...     pre-exception output
     ...     Traceback (most recent call last):
     ...     ZeroDivisionError: integer division or modulo by zero
@@ -801,7 +801,7 @@
     **********************************************************************
     File ..., line 4, in f
     Failed example:
-        print 'pre-exception output', x//0
+        print('pre-exception output', x//0)
     Exception raised:
         ...
         ZeroDivisionError: integer division or modulo by zero
@@ -942,7 +942,7 @@
 and the '<BLANKLINE>' marker:
 
     >>> def f(x):
-    ...     '>>> print "a\\n\\nb"\na\n<BLANKLINE>\nb\n'
+    ...     '>>> print("a\\n\\nb")\na\n<BLANKLINE>\nb\n'
 
     >>> # Without the flag:
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -957,7 +957,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print "a\n\nb"
+        print("a\n\nb")
     Expected:
         a
         <BLANKLINE>
@@ -972,7 +972,7 @@
 treated as equal:
 
     >>> def f(x):
-    ...     '>>> print 1, 2, 3\n  1   2\n 3'
+    ...     '>>> print(1, 2, 3)\n  1   2\n 3'
 
     >>> # Without the flag:
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -981,7 +981,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print 1, 2, 3
+        print(1, 2, 3)
     Expected:
           1   2
          3
@@ -1004,7 +1004,7 @@
 output to match any substring in the actual output:
 
     >>> def f(x):
-    ...     '>>> print range(15)\n[0, 1, 2, ..., 14]\n'
+    ...     '>>> print(range(15))\n[0, 1, 2, ..., 14]\n'
 
     >>> # Without the flag:
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -1013,7 +1013,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print range(15)
+        print(range(15))
     Expected:
         [0, 1, 2, ..., 14]
     Got:
@@ -1071,7 +1071,7 @@
 
     >>> def f(x):
     ...     r'''
-    ...     >>> print '\n'.join('abcdefg')
+    ...     >>> print('\n'.join('abcdefg'))
     ...     a
     ...     B
     ...     c
@@ -1088,7 +1088,7 @@
     **********************************************************************
     File ..., line 3, in f
     Failed example:
-        print '\n'.join('abcdefg')
+        print('\n'.join('abcdefg'))
     Expected:
         a
         B
@@ -1115,7 +1115,7 @@
     **********************************************************************
     File ..., line 3, in f
     Failed example:
-        print '\n'.join('abcdefg')
+        print('\n'.join('abcdefg'))
     Differences (unified diff with -expected +actual):
         @@ -1,7 +1,7 @@
          a
@@ -1140,7 +1140,7 @@
     **********************************************************************
     File ..., line 3, in f
     Failed example:
-        print '\n'.join('abcdefg')
+        print('\n'.join('abcdefg'))
     Differences (context diff with expected followed by actual):
         ***************
         *** 1,7 ****
@@ -1168,7 +1168,7 @@
 
     >>> def f(x):
     ...     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
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -1178,7 +1178,7 @@
     **********************************************************************
     File ..., line 3, in f
     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):
         - a b c d e f g h i j k 1 m
         ?                       ^
@@ -1191,15 +1191,15 @@
 
     >>> def f(x):
     ...     r'''
-    ...     >>> print 1 # first success
+    ...     >>> print(1) # first success
     ...     1
-    ...     >>> print 2 # first failure
+    ...     >>> print(2) # first failure
     ...     200
-    ...     >>> print 3 # second failure
+    ...     >>> print(3) # second failure
     ...     300
-    ...     >>> print 4 # second success
+    ...     >>> print(4) # second success
     ...     4
-    ...     >>> print 5 # third failure
+    ...     >>> print(5) # third failure
     ...     500
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -1209,7 +1209,7 @@
     **********************************************************************
     File ..., line 5, in f
     Failed example:
-        print 2 # first failure
+        print(2) # first failure
     Expected:
         200
     Got:
@@ -1221,18 +1221,18 @@
     >>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test)
     ... # doctest: +ELLIPSIS
     Trying:
-        print 1 # first success
+        print(1) # first success
     Expecting:
         1
     ok
     Trying:
-        print 2 # first failure
+        print(2) # first failure
     Expecting:
         200
     **********************************************************************
     File ..., line 5, in f
     Failed example:
-        print 2 # first failure
+        print(2) # first failure
     Expected:
         200
     Got:
@@ -1244,15 +1244,15 @@
 
     >>> def f(x):
     ...     r'''
-    ...     >>> print 1 # first success
+    ...     >>> print(1) # first success
     ...     1
     ...     >>> raise ValueError(2) # first failure
     ...     200
-    ...     >>> print 3 # second failure
+    ...     >>> print(3) # second failure
     ...     300
-    ...     >>> print 4 # second success
+    ...     >>> print(4) # second success
     ...     4
-    ...     >>> print 5 # third failure
+    ...     >>> print(5) # third failure
     ...     500
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -1298,10 +1298,10 @@
 example with a comment of the form ``# doctest: +OPTION``:
 
     >>> def f(x): r'''
-    ...     >>> print range(10)       # should fail: no ellipsis
+    ...     >>> print(range(10))      # should fail: no ellipsis
     ...     [0, 1, ..., 9]
     ...
-    ...     >>> print range(10)       # doctest: +ELLIPSIS
+    ...     >>> print(range(10))      # doctest: +ELLIPSIS
     ...     [0, 1, ..., 9]
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -1310,7 +1310,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print range(10)       # should fail: no ellipsis
+        print(range(10))      # should fail: no ellipsis
     Expected:
         [0, 1, ..., 9]
     Got:
@@ -1321,11 +1321,11 @@
 comment of the form ``# doctest: -OPTION``:
 
     >>> def f(x): r'''
-    ...     >>> print range(10)
+    ...     >>> print(range(10))
     ...     [0, 1, ..., 9]
     ...
     ...     >>> # should fail: no ellipsis
-    ...     >>> print range(10)       # doctest: -ELLIPSIS
+    ...     >>> print(range(10))      # doctest: -ELLIPSIS
     ...     [0, 1, ..., 9]
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -1335,7 +1335,7 @@
     **********************************************************************
     File ..., line 6, in f
     Failed example:
-        print range(10)       # doctest: -ELLIPSIS
+        print(range(10))      # doctest: -ELLIPSIS
     Expected:
         [0, 1, ..., 9]
     Got:
@@ -1346,13 +1346,13 @@
 do not change the options for surrounding examples:
 
     >>> def f(x): r'''
-    ...     >>> print range(10)       # Should fail: no ellipsis
+    ...     >>> print(range(10))      # Should fail: no ellipsis
     ...     [0, 1, ..., 9]
     ...
-    ...     >>> print range(10)       # doctest: +ELLIPSIS
+    ...     >>> print(range(10))      # doctest: +ELLIPSIS
     ...     [0, 1, ..., 9]
     ...
-    ...     >>> print range(10)       # Should fail: no ellipsis
+    ...     >>> print(range(10))      # Should fail: no ellipsis
     ...     [0, 1, ..., 9]
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -1361,7 +1361,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print range(10)       # Should fail: no ellipsis
+        print(range(10))      # Should fail: no ellipsis
     Expected:
         [0, 1, ..., 9]
     Got:
@@ -1369,7 +1369,7 @@
     **********************************************************************
     File ..., line 8, in f
     Failed example:
-        print range(10)       # Should fail: no ellipsis
+        print(range(10))      # Should fail: no ellipsis
     Expected:
         [0, 1, ..., 9]
     Got:
@@ -1380,9 +1380,9 @@
 may be separated by whitespace, commas, or both:
 
     >>> def f(x): r'''
-    ...     >>> print range(10)       # Should fail
+    ...     >>> print(range(10))      # Should fail
     ...     [0, 1,  ...,   9]
-    ...     >>> print range(10)       # Should succeed
+    ...     >>> print(range(10))      # Should succeed
     ...     ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
     ...     [0, 1,  ...,   9]
     ...     '''
@@ -1392,7 +1392,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print range(10)       # Should fail
+        print(range(10))      # Should fail
     Expected:
         [0, 1,  ...,   9]
     Got:
@@ -1400,9 +1400,9 @@
     (1, 2)
 
     >>> def f(x): r'''
-    ...     >>> print range(10)       # Should fail
+    ...     >>> print(range(10))      # Should fail
     ...     [0, 1,  ...,   9]
-    ...     >>> print range(10)       # Should succeed
+    ...     >>> print(range(10))      # Should succeed
     ...     ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE
     ...     [0, 1,  ...,   9]
     ...     '''
@@ -1412,7 +1412,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print range(10)       # Should fail
+        print(range(10))      # Should fail
     Expected:
         [0, 1,  ...,   9]
     Got:
@@ -1420,9 +1420,9 @@
     (1, 2)
 
     >>> def f(x): r'''
-    ...     >>> print range(10)       # Should fail
+    ...     >>> print(range(10))      # Should fail
     ...     [0, 1,  ...,   9]
-    ...     >>> print range(10)       # Should succeed
+    ...     >>> print(range(10))      # Should succeed
     ...     ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
     ...     [0, 1,  ...,   9]
     ...     '''
@@ -1432,7 +1432,7 @@
     **********************************************************************
     File ..., line 2, in f
     Failed example:
-        print range(10)       # Should fail
+        print(range(10))      # Should fail
     Expected:
         [0, 1,  ...,   9]
     Got:
@@ -1443,7 +1443,7 @@
 long as a continuation prompt is used:
 
     >>> def f(x): r'''
-    ...     >>> print range(10)
+    ...     >>> print(range(10))
     ...     ... # doctest: +ELLIPSIS
     ...     [0, 1, ..., 9]
     ...     '''
@@ -1456,12 +1456,12 @@
 
     >>> def f(x): r'''
     ...     >>> for x in range(10): # doctest: +ELLIPSIS
-    ...     ...     print x,
-    ...     0 1 2 ... 9
+    ...     ...     print(x, end=' ')
+    ...     0 1 2 ... 9 
     ...
     ...     >>> for x in range(10):
-    ...     ...     print x,        # doctest: +ELLIPSIS
-    ...     0 1 2 ... 9
+    ...     ...     print(x, end=' ') # doctest: +ELLIPSIS
+    ...     0 1 2 ... 9 
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
     >>> doctest.DocTestRunner(verbose=False).run(test)
@@ -1473,8 +1473,8 @@
     >>> def f(x): r'''
     ...     Should fail (option directive not on the last line):
     ...         >>> for x in range(10): # doctest: +ELLIPSIS
-    ...         ...     print x,        # doctest: +NORMALIZE_WHITESPACE
-    ...         0  1    2...9
+    ...         ...     print(x, end=' ') # doctest: +NORMALIZE_WHITESPACE
+    ...         0  1    2...9 
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
     >>> doctest.DocTestRunner(verbose=False).run(test)
@@ -1486,13 +1486,13 @@
 `register_option`:
 
     >>> # Error: Option not registered
-    >>> s = '>>> print 12   #doctest: +BADOPTION'
+    >>> s = '>>> print(12)  #doctest: +BADOPTION'
     >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0)
     Traceback (most recent call last):
     ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION'
 
     >>> # Error: No + or - prefix
-    >>> s = '>>> print 12   #doctest: ELLIPSIS'
+    >>> s = '>>> print(12)  #doctest: ELLIPSIS'
     >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0)
     Traceback (most recent call last):
     ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS'
@@ -1519,7 +1519,7 @@
     >>> print(doctest.testsource(test.test_doctest, name))
     # Blah blah
     #
-    print sample_func(22)
+    print(sample_func(22))
     # Expected:
     ## 44
     #
@@ -1528,7 +1528,7 @@
 
     >>> name = 'test.test_doctest.SampleNewStyleClass'
     >>> print(doctest.testsource(test.test_doctest, name))
-    print '1\n2\n3'
+    print('1\n2\n3')
     # Expected:
     ## 1
     ## 2
@@ -1537,10 +1537,10 @@
 
     >>> name = 'test.test_doctest.SampleClass.a_classmethod'
     >>> print(doctest.testsource(test.test_doctest, name))
-    print SampleClass.a_classmethod(10)
+    print(SampleClass.a_classmethod(10))
     # Expected:
     ## 12
-    print SampleClass(0).a_classmethod(10)
+    print(SampleClass(0).a_classmethod(10))
     # Expected:
     ## 12
     <BLANKLINE>
@@ -1552,7 +1552,7 @@
 
     >>> s = '''
     ...     >>> x = 12
-    ...     >>> print x
+    ...     >>> print(x)
     ...     12
     ...     '''
 
@@ -1560,7 +1560,7 @@
 
     >>> import tempfile
     >>> 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.
 
@@ -1571,7 +1571,7 @@
     12
     --Return--
     > <string>(1)<module>()->None
-    (Pdb) print x
+    (Pdb) print(x)
     12
     (Pdb) continue
 
@@ -1601,7 +1601,7 @@
       >>> import tempfile
       >>> real_stdin = sys.stdin
       >>> sys.stdin = _FakeInput([
-      ...    'print x',  # print data defined by the example
+      ...    'print(x)',  # print data defined by the example
       ...    'continue', # stop debugging
       ...    ''])
 
@@ -1610,7 +1610,7 @@
       --Return--
       > <doctest foo[1]>(1)<module>()->None
       -> import pdb; pdb.set_trace()
-      (Pdb) print x
+      (Pdb) print(x)
       42
       (Pdb) continue
       (0, 2)
@@ -1628,9 +1628,9 @@
       >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
       >>> real_stdin = sys.stdin
       >>> sys.stdin = _FakeInput([
-      ...    'print y',  # print data defined in the function
+      ...    'print(y)',  # print data defined in the function
       ...    'up',       # out of function
-      ...    'print x',  # print data defined by the example
+      ...    'print(x)',  # print data defined by the example
       ...    'continue', # stop debugging
       ...    ''])
 
@@ -1641,12 +1641,12 @@
       --Return--
       > <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None
       -> import pdb; pdb.set_trace()
-      (Pdb) print y
+      (Pdb) print(y)
       2
       (Pdb) up
       > <doctest foo[1]>(1)<module>()
       -> calls_set_trace()
-      (Pdb) print x
+      (Pdb) print(x)
       1
       (Pdb) continue
       (0, 2)
@@ -1658,7 +1658,7 @@
       ... >>> def f(x):
       ... ...     g(x*2)
       ... >>> def g(x):
-      ... ...     print x+3
+      ... ...     print(x+3)
       ... ...     import pdb; pdb.set_trace()
       ... >>> f(3)
       ... '''
@@ -1680,7 +1680,7 @@
       -> import pdb; pdb.set_trace()
       (Pdb) list
         1     def g(x):
-        2         print x+3
+        2         print(x+3)
         3  ->     import pdb; pdb.set_trace()
       [EOF]
       (Pdb) next
@@ -1737,11 +1737,11 @@
     >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
     >>> real_stdin = sys.stdin
     >>> sys.stdin = _FakeInput([
-    ...    'print y',  # print data defined in the function
-    ...    'step', 'step', 'step', 'step', 'step', 'step', 'print z',
-    ...    'up', 'print x',
-    ...    'up', 'print y',
-    ...    'up', 'print foo',
+    ...    'print(y)',  # print data defined in the function
+    ...    'step', 'step', 'step', 'step', 'step', 'step', 'print(z)',
+    ...    'up', 'print(x)',
+    ...    'up', 'print(y)',
+    ...    'up', 'print(foo)',
     ...    'continue', # stop debugging
     ...    ''])
 
@@ -1751,7 +1751,7 @@
     ...     sys.stdin = real_stdin
     > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
     -> self.f1()
-    (Pdb) print y
+    (Pdb) print(y)
     1
     (Pdb) step
     --Call--
@@ -1773,22 +1773,22 @@
     (Pdb) step
     > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(13)f2()
     -> z = 2
-    (Pdb) print z
+    (Pdb) print(z)
     1
     (Pdb) up
     > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1()
     -> self.f2()
-    (Pdb) print x
+    (Pdb) print(x)
     1
     (Pdb) up
     > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
     -> self.f1()
-    (Pdb) print y
+    (Pdb) print(y)
     1
     (Pdb) up
     > <doctest foo[1]>(1)<module>()
     -> calls_set_trace()
-    (Pdb) print foo
+    (Pdb) print(foo)
     *** NameError: name 'foo' is not defined
     (Pdb) continue
     (0, 2)
@@ -2099,9 +2099,9 @@
       ...
       Failed example:
           if 1:
-             print 'a'
-             print
-             print 'b'
+             print('a')
+             print()
+             print('b')
       Differences (ndiff with -expected +actual):
             a
           - <BLANKLINE>
@@ -2185,9 +2185,9 @@
     ok
     Trying:
         if 1:
-           print 'a'
-           print
-           print 'b'
+           print('a')
+           print()
+           print('b')
     Expecting:
         a
         <BLANKLINE>
@@ -2279,19 +2279,19 @@
 >>> t = Tester(globs={'x': 42}, verbose=0)
 >>> t.runstring(r'''
 ...      >>> x = x * 2
-...      >>> print x
+...      >>> print(x)
 ...      42
 ... ''', 'XYZ')
 **********************************************************************
 Line 3, in XYZ
 Failed example:
-    print x
+    print(x)
 Expected:
     42
 Got:
     84
 (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)
 >>> t.summarize()
 **********************************************************************


More information about the Python-3000-checkins mailing list