diff options
Diffstat (limited to 'Lib/test/test_descrtut.py')
-rw-r--r-- | Lib/test/test_descrtut.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py index 506d1ab..80cfa41 100644 --- a/Lib/test/test_descrtut.py +++ b/Lib/test/test_descrtut.py @@ -37,16 +37,16 @@ test_1 = """ Here's the new type at work: >>> print(defaultdict) # show our type - <class 'test.test_descrtut.defaultdict'> + <class 'test.test_descrtut.defaultdict' ...> >>> print(type(defaultdict)) # its metatype - <class 'type'> + <class 'type' ...> >>> a = defaultdict(default=0.0) # create an instance >>> print(a) # show the instance {} >>> print(type(a)) # show its type - <class 'test.test_descrtut.defaultdict'> + <class 'test.test_descrtut.defaultdict' ...> >>> print(a.__class__) # show its class - <class 'test.test_descrtut.defaultdict'> + <class 'test.test_descrtut.defaultdict' ...> >>> print(type(a) is a.__class__) # its type is its class True >>> a[1] = 3.25 # modify the instance @@ -149,11 +149,11 @@ Introspecting instances of built-in types For instance of built-in types, x.__class__ is now the same as type(x): >>> type([]) - <class 'list'> + <class 'list' ...> >>> [].__class__ - <class 'list'> + <class 'list' ...> >>> list - <class 'list'> + <class 'list' ...> >>> isinstance([], list) True >>> isinstance([], dict) @@ -258,19 +258,19 @@ implicit first argument that is the *class* for which they are invoked. ... print("classmethod", cls, y) >>> C.foo(1) - classmethod <class 'test.test_descrtut.C'> 1 + classmethod <class 'test.test_descrtut.C' ...> 1 >>> c = C() >>> c.foo(1) - classmethod <class 'test.test_descrtut.C'> 1 + classmethod <class 'test.test_descrtut.C' ...> 1 >>> class D(C): ... pass >>> D.foo(1) - classmethod <class 'test.test_descrtut.D'> 1 + classmethod <class 'test.test_descrtut.D' ...> 1 >>> d = D() >>> d.foo(1) - classmethod <class 'test.test_descrtut.D'> 1 + classmethod <class 'test.test_descrtut.D' ...> 1 This prints "classmethod __main__.D 1" both times; in other words, the class passed as the first argument of foo() is the class involved in the @@ -286,11 +286,11 @@ But notice this: >>> E.foo(1) E.foo() called - classmethod <class 'test.test_descrtut.C'> 1 + classmethod <class 'test.test_descrtut.C' ...> 1 >>> e = E() >>> e.foo(1) E.foo() called - classmethod <class 'test.test_descrtut.C'> 1 + classmethod <class 'test.test_descrtut.C' ...> 1 In this example, the call to C.foo() from E.foo() will see class C as its first argument, not class E. This is to be expected, since the call @@ -350,7 +350,7 @@ Hmm -- property is builtin now, so let's try it that way too. >>> del property # unmask the builtin >>> property - <class 'property'> + <class 'property' ...> >>> class C(object): ... def __init__(self): @@ -478,7 +478,8 @@ def test_main(verbose=None): # business is used the name can change depending on how the test is # invoked. from test import support, test_descrtut - support.run_doctest(test_descrtut, verbose) + import doctest + support.run_doctest(test_descrtut, verbose, optionflags=doctest.ELLIPSIS) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": |