summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-02-09 22:43:47 (GMT)
committerGuido van Rossum <guido@python.org>2007-02-09 22:43:47 (GMT)
commitbdc36e4d9e754dd00f17f67a943217a1829c75b3 (patch)
treed846b89ffa8e4f5184abaa260de3875b491d1b78 /Lib/test
parent0bcbb0d4d48162195382d35f3cf63a2fdee46374 (diff)
downloadcpython-bdc36e4d9e754dd00f17f67a943217a1829c75b3.zip
cpython-bdc36e4d9e754dd00f17f67a943217a1829c75b3.tar.gz
cpython-bdc36e4d9e754dd00f17f67a943217a1829c75b3.tar.bz2
Redue the failure rate to 13 tests. Bah.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_doctest.py270
1 files changed, 135 insertions, 135 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index e7f84ae..f3ee247 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -35,7 +35,7 @@ class SampleClass:
>>> 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 @@ Example is a simple container class that holds:
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 @@ keyword arguments:
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 `source` string to end in a newline:
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 @@ filename, and line number). The docstring is parsed by the `DocTest`
constructor:
>>> docstring = '''
- ... >>> print 12
+ ... >>> print(12)
... 12
...
... Non-example text.
...
- ... >>> print 'another\example'
+ ... >>> print('another\example')
... another
... example
... '''
@@ -284,9 +284,9 @@ constructor:
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 @@ If the docstring contains inconsistant leading whitespace in the
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 @@ If the docstring contains inconsistent leading whitespace on
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 @@ continuation lines, then `DocTest` will raise a ValueError:
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 @@ leading path components.
>>> 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 @@ functions, classes, and the `__test__` dictionary, if it exists:
>>> m = new.module('some_module')
>>> def triple(val):
... '''
- ... >>> print triple(11)
+ ... >>> print(triple(11))
... 33
... '''
... return val*3
@@ -461,11 +461,11 @@ functions, classes, and the `__test__` dictionary, if it exists:
... '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 @@ DocTestFinder finds the line number of each example:
... ...
...
... >>> 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 @@ text:
>>> 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:
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 @@ The `get_examples` method returns just the examples:
>>> 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 @@ given arguments:
>>> 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 @@ statistics. Here's a simple DocTest case we can use:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 12
... >>> x//2
... 6
@@ -666,7 +666,7 @@ the failure and proceeds to the next example:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 14
... >>> x//2
... 6
@@ -679,13 +679,13 @@ the failure and proceeds to the next example:
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 @@ output:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 12
... >>> x//2
... 6
@@ -717,7 +717,7 @@ output:
Expecting nothing
ok
Trying:
- print x
+ print(x)
Expecting:
12
ok
@@ -747,7 +747,7 @@ iff `-v` appears in sys.argv:
Expecting nothing
ok
Trying:
- print x
+ print(x)
Expecting:
12
ok
@@ -774,7 +774,7 @@ replaced with any other string:
>>> 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 @@ unexpected exception:
>>> 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 @@ unexpected exception:
**********************************************************************
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 @@ The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines
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 @@ and the '<BLANKLINE>' marker:
**********************************************************************
File ..., line 2, in f
Failed example:
- print "a\n\nb"
+ print("a\n\nb")
Expected:
a
<BLANKLINE>
@@ -972,7 +972,7 @@ The NORMALIZE_WHITESPACE flag causes all sequences of whitespace to be
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 @@ treated as equal:
**********************************************************************
File ..., line 2, in f
Failed example:
- print 1, 2, 3
+ print(1, 2, 3)
Expected:
1 2
3
@@ -1004,7 +1004,7 @@ The ELLIPSIS flag causes ellipsis marker ("...") in the expected
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 @@ output to match any substring in the actual output:
**********************************************************************
File ..., line 2, in f
Failed example:
- print range(15)
+ print(range(15))
Expected:
[0, 1, 2, ..., 14]
Got:
@@ -1071,7 +1071,7 @@ and actual outputs to be displayed using a unified diff:
>>> def f(x):
... r'''
- ... >>> print '\n'.join('abcdefg')
+ ... >>> print('\n'.join('abcdefg'))
... a
... B
... c
@@ -1088,7 +1088,7 @@ and actual outputs to be displayed using a unified diff:
**********************************************************************
File ..., line 3, in f
Failed example:
- print '\n'.join('abcdefg')
+ print('\n'.join('abcdefg'))
Expected:
a
B
@@ -1115,7 +1115,7 @@ and actual outputs to be displayed using a unified diff:
**********************************************************************
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 @@ and actual outputs to be displayed using a context diff:
**********************************************************************
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 @@ marking, as well as interline differences.
>>> 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 @@ marking, as well as interline differences.
**********************************************************************
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 @@ failing example:
>>> 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 @@ failing example:
**********************************************************************
File ..., line 5, in f
Failed example:
- print 2 # first failure
+ print(2) # first failure
Expected:
200
Got:
@@ -1221,18 +1221,18 @@ However, output from `report_start` is not supressed:
>>> 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 @@ count as failures:
>>> 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 @@ single example. To turn an option on for an example, follow that
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 @@ example with a comment of the form ``# doctest: +OPTION``:
**********************************************************************
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 @@ To turn an option off for an example, follow that example with a
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 @@ comment of the form ``# doctest: -OPTION``:
**********************************************************************
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 @@ Option directives affect only the example that they appear with; they
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 @@ do not change the options for surrounding examples:
**********************************************************************
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 @@ do not change the options for surrounding examples:
**********************************************************************
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 @@ Multiple options may be modified by a single option directive. They
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 @@ may be separated by whitespace, commas, or both:
**********************************************************************
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 @@ may be separated by whitespace, commas, or both:
(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 @@ may be separated by whitespace, commas, or both:
**********************************************************************
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 @@ may be separated by whitespace, commas, or both:
(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 @@ may be separated by whitespace, commas, or both:
**********************************************************************
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 @@ The option directive may be put on the line following the source, as
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 @@ at the end of any line:
>>> 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 @@ option directive, then they are combined:
>>> 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 @@ It is an error to have a comment of the form ``# doctest:`` that is
`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 @@ words and expected output are converted to comments:
>>> print(doctest.testsource(test.test_doctest, name))
# Blah blah
#
- print sample_func(22)
+ print(sample_func(22))
# Expected:
## 44
#
@@ -1528,7 +1528,7 @@ words and expected output are converted to comments:
>>> 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 @@ words and expected output are converted to comments:
>>> 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 @@ Create a docstring that we want to debug:
>>> s = '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 12
... '''
@@ -1560,7 +1560,7 @@ Create some fake stdin input, to feed to the debugger:
>>> 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 @@ Run the debugger on the docstring, and then restore sys.stdin.
12
--Return--
> <string>(1)<module>()->None
- (Pdb) print x
+ (Pdb) print(x)
12
(Pdb) continue
@@ -1601,7 +1601,7 @@ def test_pdb_set_trace():
>>> 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 @@ def test_pdb_set_trace():
--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 @@ def test_pdb_set_trace():
>>> 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 @@ def test_pdb_set_trace():
--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 test_pdb_set_trace():
... >>> 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 @@ def test_pdb_set_trace():
-> 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 @@ def test_pdb_set_trace_nested():
>>> 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 @@ def test_pdb_set_trace_nested():
... 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 @@ def test_pdb_set_trace_nested():
(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 @@ def test_unittest_reportflags():
...
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 @@ Verbosity can be increased with the optional `verbose` paremter:
ok
Trying:
if 1:
- print 'a'
- print
- print 'b'
+ print('a')
+ print()
+ print('b')
Expecting:
a
<BLANKLINE>
@@ -2279,19 +2279,19 @@ def old_test1(): r"""
>>> 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()
**********************************************************************