6932N/Atest (__main__.DocumentationTestCase) ... ok
6932N/Atest_singledispatch1 (__main__.DocumentationTestCase) ... ok
6932N/Atest_singledispatch2 (__main__.DocumentationTestCase) ... ok
6932N/Atest_no_first_arg (__main__.ExtraTestCase) ... ok
6932N/Atest_qualname (__main__.ExtraTestCase) ... ok
6932N/Atest_signature (__main__.ExtraTestCase) ... ok
6932N/Atest_unique_filenames (__main__.ExtraTestCase) ... ok
6932N/Atest_c_classes (__main__.TestSingleDispatch) ... ok
6932N/Atest_mro (__main__.TestSingleDispatch) ... ok
6932N/Atest_mro_conflicts (__main__.TestSingleDispatch) ... ok
6932N/Atest_register_abc (__main__.TestSingleDispatch) ... ok
6932N/Atest_register_decorator (__main__.TestSingleDispatch) ... ok
6932N/Atest_register_error (__main__.TestSingleDispatch) ... ok
6932N/Atest_simple_overloads (__main__.TestSingleDispatch) ... ok
6932N/Atest_wrapping_attributes (__main__.TestSingleDispatch) ... ok
6932N/A
6932N/A----------------------------------------------------------------------
6932N/ARan 15 tests in
6932N/A
6932N/AOK
6932N/ATrying:
6932N/A from decorator import getargspec # akin to inspect.getargspec
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(getargspec(f1))
6932N/AExpecting:
6932N/A ArgSpec(args=[], varargs='args', varkw='kw', defaults=None)
6932N/Aok
6932N/ATrying:
6932N/A f1(0, 1) # doctest: +IGNORE_EXCEPTION_DETAIL
6932N/AExpecting:
6932N/A Traceback (most recent call last):
6932N/A ...
6932N/A TypeError: f1() takes exactly 1 positional argument (2 given)
6932N/Aok
6932N/ATrying:
6932N/A from decorator import decorate
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A @memoize
6932N/A def heavy_computation():
6932N/A time.sleep(2)
6932N/A return "done"
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(heavy_computation()) # the first time it will take 2 seconds
6932N/AExpecting:
6932N/A done
6932N/Aok
6932N/ATrying:
6932N/A print(heavy_computation()) # the second time it will be instantaneous
6932N/AExpecting:
6932N/A done
6932N/Aok
6932N/ATrying:
6932N/A print(getargspec(heavy_computation))
6932N/AExpecting:
6932N/A ArgSpec(args=[], varargs=None, varkw=None, defaults=None)
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f1(x):
6932N/A pass
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f1(0)
6932N/AExpecting:
6932N/A calling f1 with args (0,), {}
6932N/Aok
6932N/ATrying:
6932N/A print(getargspec(f1))
6932N/AExpecting:
6932N/A ArgSpec(args=['x'], varargs=None, varkw=None, defaults=None)
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f(x, y=1, z=2, *args, **kw):
6932N/A pass
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f(0, 3)
6932N/AExpecting:
6932N/A calling f with args (0, 3, 2), {}
6932N/Aok
6932N/ATrying:
6932N/A print(getargspec(f))
6932N/AExpecting:
6932N/A ArgSpec(args=['x', 'y', 'z'], varargs='args', varkw='kw', defaults=(1, 2))
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f(x: 'the first argument', y: 'default argument'=1, z=2,
6932N/A *args: 'varargs', **kw: 'kwargs'):
6932N/A pass
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A from inspect import getfullargspec
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A argspec = getfullargspec(f)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A argspec.args
6932N/AExpecting:
6932N/A ['x', 'y', 'z']
6932N/Aok
6932N/ATrying:
6932N/A argspec.varargs
6932N/AExpecting:
6932N/A 'args'
6932N/Aok
6932N/ATrying:
6932N/A argspec.varkw
6932N/AExpecting:
6932N/A 'kw'
6932N/Aok
6932N/ATrying:
6932N/A argspec.defaults
6932N/AExpecting:
6932N/A (1, 2)
6932N/Aok
6932N/ATrying:
6932N/A argspec.kwonlyargs
6932N/AExpecting:
6932N/A []
6932N/Aok
6932N/ATrying:
6932N/A argspec.kwonlydefaults
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f.__annotations__ is f.__wrapped__.__annotations__
6932N/AExpecting:
6932N/A True
6932N/Aok
6932N/ATrying:
6932N/A from decorator import decorator
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(decorator.__doc__)
6932N/AExpecting:
6932N/A decorator(caller) converts a caller function into a decorator
6932N/Aok
6932N/ATrying:
6932N/A @decorator
6932N/A def trace(f, *args, **kw):
6932N/A kwstr = ', '.join('%r: %r' % (k, kw[k]) for k in sorted(kw))
6932N/A print("calling %s with args %s, {%s}" % (f.__name__, args, kwstr))
6932N/A return f(*args, **kw)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A trace # doctest: +ELLIPSIS
6932N/AExpecting:
6932N/A <function trace at 0x...>
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def func(): pass
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A func()
6932N/AExpecting:
6932N/A calling func with args (), {}
6932N/Aok
6932N/ATrying:
6932N/A @blocking("Please wait ...")
6932N/A def read_data():
6932N/A time.sleep(3) # simulate a blocking resource
6932N/A return "some data"
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(read_data()) # data is not available yet
6932N/AExpecting:
6932N/A Please wait ...
6932N/Aok
6932N/ATrying:
6932N/A time.sleep(1)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(read_data()) # data is not available yet
6932N/AExpecting:
6932N/A Please wait ...
6932N/Aok
6932N/ATrying:
6932N/A time.sleep(1)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(read_data()) # data is not available yet
6932N/AExpecting:
6932N/A Please wait ...
6932N/Aok
6932N/ATrying:
6932N/A time.sleep(1.1) # after 3.1 seconds, data is available
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(read_data())
6932N/AExpecting:
6932N/A some data
6932N/Aok
6932N/ATrying:
6932N/A @decorator(Future)
6932N/A def long_running(x):
6932N/A time.sleep(.5)
6932N/A return x
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A fut1 = long_running(1)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A fut2 = long_running(2)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A fut1.result() + fut2.result()
6932N/AExpecting:
6932N/A 3
6932N/Aok
6932N/ATrying:
6932N/A from contextlib import contextmanager
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A @contextmanager
6932N/A def before_after(before, after):
6932N/A print(before)
6932N/A yield
6932N/A print(after)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A with before_after('BEFORE', 'AFTER'):
6932N/A print('hello')
6932N/AExpecting:
6932N/A BEFORE
6932N/A hello
6932N/A AFTER
6932N/Aok
6932N/ATrying:
6932N/A def f(*args, **kw): # a function with a generic signature
6932N/A print(args, kw)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f1 = FunctionMaker.create('f1(a, b)', 'f(a, b)', dict(f=f))
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f1(1,2)
6932N/AExpecting:
6932N/A (1, 2) {}
6932N/Aok
6932N/ATrying:
6932N/A f1 = FunctionMaker.create(
6932N/A 'f1(a, b)', 'f(a, b)', dict(f=f), addsource=True)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(f1.__source__)
6932N/AExpecting:
6932N/A def f1(a, b):
6932N/A f(a, b)
6932N/A <BLANKLINE>
6932N/Aok
6932N/ATrying:
6932N/A f1 = FunctionMaker.create(
6932N/A 'f1(a, b)', 'f(a, b)', dict(f=f), addsource=True, defaults=(None,))
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(getargspec(f1))
6932N/AExpecting:
6932N/A ArgSpec(args=['a', 'b'], varargs=None, varkw=None, defaults=(None,))
6932N/Aok
6932N/ATrying:
6932N/A import inspect
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A print(inspect.getsource(example))
6932N/AExpecting:
6932N/A def wrapper(*args, **kw):
6932N/A return func(*args, **kw)
6932N/A <BLANKLINE>
6932N/Aok
6932N/ATrying:
6932N/A print(inspect.getsource(factorial.__wrapped__))
6932N/AExpecting:
6932N/A @tail_recursive
6932N/A def factorial(n, acc=1):
6932N/A "The good old factorial"
6932N/A if n == 0:
6932N/A return acc
6932N/A return factorial(n-1, n*acc)
6932N/A <BLANKLINE>
6932N/Aok
6932N/ATrying:
6932N/A print(factorial(4))
6932N/AExpecting:
6932N/A 24
6932N/Aok
6932N/ATrying:
6932N/A writer = XMLWriter()
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A writer.write(2.3)
6932N/AExpecting:
6932N/A '<float>2.3</float>'
6932N/Aok
6932N/ATrying:
6932N/A win(Paper(), Rock())
6932N/AExpecting:
6932N/A 1
6932N/Aok
6932N/ATrying:
6932N/A win(Scissors(), Paper())
6932N/AExpecting:
6932N/A 1
6932N/Aok
6932N/ATrying:
6932N/A win(Rock(), Scissors())
6932N/AExpecting:
6932N/A 1
6932N/Aok
6932N/ATrying:
6932N/A win(Paper(), Paper())
6932N/AExpecting:
6932N/A 0
6932N/Aok
6932N/ATrying:
6932N/A win(Rock(), Rock())
6932N/AExpecting:
6932N/A 0
6932N/Aok
6932N/ATrying:
6932N/A win(Scissors(), Scissors())
6932N/AExpecting:
6932N/A 0
6932N/Aok
6932N/ATrying:
6932N/A win(Rock(), Paper())
6932N/AExpecting:
6932N/A -1
6932N/Aok
6932N/ATrying:
6932N/A win(Paper(), Scissors())
6932N/AExpecting:
6932N/A -1
6932N/Aok
6932N/ATrying:
6932N/A win(Scissors(), Rock())
6932N/AExpecting:
6932N/A -1
6932N/Aok
6932N/ATrying:
6932N/A win(StrongRock(), Scissors())
6932N/AExpecting:
6932N/A 1
6932N/Aok
6932N/ATrying:
6932N/A win.dispatch_info(StrongRock, Scissors)
6932N/AExpecting:
6932N/A [('StrongRock', 'Scissors'), ('Rock', 'Scissors')]
6932N/Aok
6932N/ATrying:
6932N/A issubclass(WithLength, collections.Sized)
6932N/AExpecting:
6932N/A True
6932N/Aok
6932N/ATrying:
6932N/A get_length(WithLength())
6932N/AExpecting:
6932N/A 0
6932N/Aok
6932N/ATrying:
6932N/A _ = collections.Set.register(SomeSet)
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A issubclass(SomeSet, collections.Set)
6932N/AExpecting:
6932N/A True
6932N/Aok
6932N/ATrying:
6932N/A get_length(SomeSet()) # NB: the implementation for Sized would give 0
6932N/AExpecting:
6932N/A 1
6932N/Aok
6932N/ATrying:
6932N/A g, V = singledispatch_example2()
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A g.dispatch_info(V)
6932N/AExpecting:
6932N/A [('V',), ('Sized',), ('S',), ('Container',)]
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f():
6932N/A 1/0
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f() # doctest: +ELLIPSIS
6932N/AExpecting:
6932N/A Traceback (most recent call last):
6932N/A ...
6932N/A File "<string>", line 2, in f
6932N/A File "<doctest __main__[22]>", line 4, in trace
6932N/A return f(*args, **kw)
6932N/A File "<doctest __main__[51]>", line 3, in f
6932N/A 1/0
6932N/A ZeroDivisionError: ...
6932N/Aok
6932N/ATrying:
6932N/A @memoize
6932N/A def getkeys(**kw):
6932N/A return kw.keys()
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A getkeys(func='a') # doctest: +ELLIPSIS
6932N/AExpecting:
6932N/A Traceback (most recent call last):
6932N/A ...
6932N/A TypeError: _memoize() got multiple values for ... 'func'
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f(_func_): print(f)
6932N/AExpecting:
6932N/A Traceback (most recent call last):
6932N/A ...
6932N/A NameError: _func_ is overridden in
6932N/A def f(_func_):
6932N/A return _call_(_func_, _func_)
6932N/Aok
6932N/ATrying:
6932N/A def f(): pass # the original function
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f.attr1 = "something" # setting an attribute
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f.attr2 = "something else" # setting another attribute
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A traced_f = trace(f) # the decorated function
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A traced_f.attr1
6932N/AExpecting:
6932N/A 'something'
6932N/Aok
6932N/ATrying:
6932N/A traced_f.attr2 = "something different" # setting attr
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f.attr2 # the original attribute did not change
6932N/AExpecting:
6932N/A 'something else'
6932N/Aok
6932N/ATrying:
6932N/A a = Action()
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A a.view() # ok
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A a.insert() # doctest: +IGNORE_EXCEPTION_DETAIL
6932N/AExpecting:
6932N/A Traceback (most recent call last):
6932N/A ...
6932N/A PermissionError: User does not have the permission to run insert!
6932N/Aok
6932N/ATrying:
6932N/A decorator(_memoize).__name__
6932N/AExpecting:
6932N/A '_memoize'
6932N/Aok
6932N/ATrying:
6932N/A factorial.__doc__
6932N/AExpecting:
6932N/A 'The good old factorial'
6932N/Aok
6932N/ATrying:
6932N/A ba.__class__.__name__
6932N/AExpecting:
6932N/A 'ContextManager'
6932N/Aok
6932N/ATrying:
6932N/A hello('michele')
6932N/AExpecting:
6932N/A BEFORE
6932N/A hello michele
6932N/A AFTER
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f(**kw): pass
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f()
6932N/AExpecting:
6932N/A calling f with args (), {}
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f(*, a=1, **kw): pass
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A import inspect
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A inspect.getfullargspec(f)
6932N/AExpecting:
6932N/A FullArgSpec(args=[], varargs=None, varkw='kw', defaults=None, kwonlyargs=['a'], kwonlydefaults={'a': 1}, annotations={})
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def func(a, b, *args, y=2, z=3, **kwargs):
6932N/A return y, z
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A func('a', 'b', 'c', 'd', 'e', y='y', z='z', cat='dog')
6932N/AExpecting:
6932N/A calling func with args ('a', 'b', 'c', 'd', 'e'), {'cat': 'dog', 'y': 'y', 'z': 'z'}
6932N/A ('y', 'z')
6932N/Aok
6932N/ATrying:
6932N/A @trace
6932N/A def f(arg, defarg=1, *args, kwonly=2): pass
6932N/AExpecting nothing
6932N/Aok
6932N/ATrying:
6932N/A f.__kwdefaults__
6932N/AExpecting:
6932N/A {'kwonly': 2}
6932N/Aok
6932N/A52 items had no tests:
6932N/A documentation.Action.delete
6932N/A documentation.Action.insert
6932N/A documentation.Action.view
6932N/A documentation.Admin
6932N/A documentation.C
6932N/A documentation.Future
6932N/A documentation.Future.__init__
6932N/A documentation.Future.result
6932N/A documentation.Paper
6932N/A documentation.PermissionError
6932N/A documentation.PowerUser
6932N/A documentation.Rock
6932N/A documentation.Scissors
6932N/A documentation.SomeSet
6932N/A documentation.SomeSet.__len__
6932N/A documentation.StrongRock
6932N/A documentation.TailRecursive
6932N/A documentation.TailRecursive.__call__
6932N/A documentation.TailRecursive.__init__
6932N/A documentation.User
6932N/A documentation.WithLength
6932N/A documentation.WithLength.__len__
6932N/A documentation.XMLWriter
6932N/A documentation.XMLWriter.__init__
6932N/A documentation.XMLWriter.write
6932N/A documentation._memoize
6932N/A documentation._trace
6932N/A documentation.before_after
6932N/A documentation.blocking
6932N/A documentation.decorator_apply
6932N/A documentation.example
6932N/A documentation.f1
6932N/A documentation.fact
6932N/A documentation.factorial
6932N/A documentation.get_length
6932N/A documentation.get_length_set
6932N/A documentation.get_length_sized
6932N/A documentation.get_userclass
6932N/A documentation.identity_dec
6932N/A documentation.memoize
6932N/A documentation.memoize_uw
6932N/A documentation.restricted
6932N/A documentation.singledispatch_example1
6932N/A documentation.singledispatch_example2
6932N/A documentation.tail_recursive
6932N/A documentation.trace
6932N/A documentation.win
6932N/A documentation.winPaperScissors
6932N/A documentation.winRockPaper
6932N/A documentation.winRockScissors
6932N/A documentation.winStrongRockPaper
6932N/A documentation.writefloat
6932N/A8 items passed all tests:
6932N/A 88 tests in documentation
6932N/A 3 tests in documentation.Action
6932N/A 2 tests in documentation.a_test_for_pylons
6932N/A 2 tests in documentation.hello
6932N/A 2 tests in documentation.test_kwonly_no_args
6932N/A 3 tests in documentation.test_kwonly_star_notation
6932N/A 2 tests in documentation.test_kwonlyargs
6932N/A 2 tests in documentation.test_kwonlydefaults
6932N/A104 tests in 60 items.
6932N/A104 passed and 0 failed.
6932N/ATest passed.