diff options
Diffstat (limited to 'Lib/test/test_doctest2.py')
-rw-r--r-- | Lib/test/test_doctest2.py | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py index 8c043baf5d1..347a1436410 100644 --- a/Lib/test/test_doctest2.py +++ b/Lib/test/test_doctest2.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- -u"""A module to test whether doctest recognizes some 2.2 features, +"""A module to test whether doctest recognizes some 2.2 features, like static and class methods. ->>> print 'yup' # 1 +>>> print('yup') # 1 yup We include some (random) encoded (utf-8) text in the text surrounding @@ -14,14 +13,14 @@ the example. It should be ignored: import sys import unittest -from test import test_support +from test import support if sys.flags.optimize >= 2: raise unittest.SkipTest("Cannot test docstrings with -O2") class C(object): - u"""Class C. + """Class C. - >>> print C() # 2 + >>> print(C()) # 2 42 @@ -35,13 +34,13 @@ class C(object): def __init__(self): """C.__init__. - >>> print C() # 3 + >>> print(C()) # 3 42 """ def __str__(self): """ - >>> print C() # 4 + >>> print(C()) # 4 42 """ return "42" @@ -49,13 +48,13 @@ class C(object): class D(object): """A nested D class. - >>> print "In D!" # 5 + >>> print("In D!") # 5 In D! """ def nested(self): """ - >>> print 3 # 6 + >>> print(3) # 6 3 """ @@ -63,7 +62,7 @@ class C(object): """ >>> c = C() # 7 >>> c.x = 12 # 8 - >>> print c.x # 9 + >>> print(c.x) # 9 -12 """ return -self._x @@ -72,7 +71,7 @@ class C(object): """ >>> c = C() # 10 >>> c.x = 12 # 11 - >>> print c.x # 12 + >>> print(c.x) # 12 -12 """ self._x = value @@ -80,7 +79,7 @@ class C(object): x = property(getx, setx, doc="""\ >>> c = C() # 13 >>> c.x = 12 # 14 - >>> print c.x # 15 + >>> print(c.x) # 15 -12 """) @@ -89,9 +88,9 @@ class C(object): """ A static method. - >>> print C.statm() # 16 + >>> print(C.statm()) # 16 666 - >>> print C().statm() # 17 + >>> print(C().statm()) # 17 666 """ return 666 @@ -101,9 +100,9 @@ class C(object): """ A class method. - >>> print C.clsm(22) # 18 + >>> print(C.clsm(22)) # 18 22 - >>> print C().clsm(23) # 19 + >>> print(C().clsm(23)) # 19 23 """ return val @@ -111,9 +110,9 @@ class C(object): def test_main(): from test import test_doctest2 EXPECTED = 19 - f, t = test_support.run_doctest(test_doctest2) + f, t = support.run_doctest(test_doctest2) if t != EXPECTED: - raise test_support.TestFailed("expected %d tests to run, not %d" % + raise support.TestFailed("expected %d tests to run, not %d" % (EXPECTED, t)) # Pollute the namespace with a bunch of imported functions and classes, |