diff -r e1fa2aa7bad7 -r e72eb275185d components/python/decorator/test/results-3.4-32.master --- a/components/python/decorator/test/results-3.4-32.master Tue Sep 20 08:35:58 2016 -0700 +++ b/components/python/decorator/test/results-3.4-32.master Tue Sep 20 08:43:49 2016 -0700 @@ -1,18 +1,31 @@ +test (__main__.DocumentationTestCase) ... ok +test_singledispatch1 (__main__.DocumentationTestCase) ... ok +test_singledispatch2 (__main__.DocumentationTestCase) ... ok +test_no_first_arg (__main__.ExtraTestCase) ... ok +test_qualname (__main__.ExtraTestCase) ... ok +test_signature (__main__.ExtraTestCase) ... ok +test_unique_filenames (__main__.ExtraTestCase) ... ok +test_c_classes (__main__.TestSingleDispatch) ... ok +test_mro (__main__.TestSingleDispatch) ... ok +test_mro_conflicts (__main__.TestSingleDispatch) ... ok +test_register_abc (__main__.TestSingleDispatch) ... ok +test_register_decorator (__main__.TestSingleDispatch) ... ok +test_register_error (__main__.TestSingleDispatch) ... ok +test_simple_overloads (__main__.TestSingleDispatch) ... ok +test_wrapping_attributes (__main__.TestSingleDispatch) ... ok + +---------------------------------------------------------------------- +Ran 15 tests in + +OK Trying: - @memoize_uw - def f1(x): - time.sleep(1) # simulate some long computation - return x -Expecting nothing -ok -Trying: - from inspect import getargspec + from decorator import getargspec # akin to inspect.getargspec Expecting nothing ok Trying: print(getargspec(f1)) Expecting: - ArgSpec(args=[], varargs='args', keywords='kw', defaults=None) + ArgSpec(args=[], varargs='args', varkw='kw', defaults=None) ok Trying: f1(0, 1) # doctest: +IGNORE_EXCEPTION_DETAIL @@ -22,7 +35,7 @@ TypeError: f1() takes exactly 1 positional argument (2 given) ok Trying: - from decorator import decorator + from decorator import decorate Expecting nothing ok Trying: @@ -43,9 +56,9 @@ done ok Trying: - print(getargspec(heavy_computation)) + print(getargspec(heavy_computation)) Expecting: - ArgSpec(args=[], varargs=None, keywords=None, defaults=None) + ArgSpec(args=[], varargs=None, varkw=None, defaults=None) ok Trying: @trace @@ -59,9 +72,9 @@ calling f1 with args (0,), {} ok Trying: - print(getargspec(f1)) + print(getargspec(f1)) Expecting: - ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None) + ArgSpec(args=['x'], varargs=None, varkw=None, defaults=None) ok Trying: @trace @@ -75,9 +88,9 @@ calling f with args (0, 3, 2), {} ok Trying: - print(getargspec(f)) + print(getargspec(f)) Expecting: - ArgSpec(args=['x', 'y', 'z'], varargs='args', keywords='kw', defaults=(1, 2)) + ArgSpec(args=['x', 'y', 'z'], varargs='args', varkw='kw', defaults=(1, 2)) ok Trying: @trace @@ -87,7 +100,7 @@ Expecting nothing ok Trying: - from inspect import getfullargspec + from inspect import getfullargspec Expecting nothing ok Trying: @@ -124,11 +137,20 @@ Expecting nothing ok Trying: - f.__annotations__ == f.__wrapped__.__annotations__ + f.__annotations__ is f.__wrapped__.__annotations__ Expecting: True ok Trying: + from decorator import decorator +Expecting nothing +ok +Trying: + print(decorator.__doc__) +Expecting: + decorator(caller) converts a caller function into a decorator +ok +Trying: @decorator def trace(f, *args, **kw): kwstr = ', '.join('%r: %r' % (k, kw[k]) for k in sorted(kw)) @@ -159,16 +181,7 @@ Expecting nothing ok Trying: - print(read_data()) # data is not available yet -Expecting: - Please wait ... -ok -Trying: - time.sleep(1) -Expecting nothing -ok -Trying: - print(read_data()) # data is not available yet + print(read_data()) # data is not available yet Expecting: Please wait ... ok @@ -177,12 +190,21 @@ Expecting nothing ok Trying: - print(read_data()) # data is not available yet + print(read_data()) # data is not available yet Expecting: Please wait ... ok Trying: - time.sleep(1.1) # after 3.1 seconds, data is available + time.sleep(1) +Expecting nothing +ok +Trying: + print(read_data()) # data is not available yet +Expecting: + Please wait ... +ok +Trying: + time.sleep(1.1) # after 3.1 seconds, data is available Expecting nothing ok Trying: @@ -191,45 +213,24 @@ some data ok Trying: - async = decorator(Async(threading.Thread)) -Expecting nothing -ok -Trying: - datalist = [] # for simplicity the written data are stored into a list. -Expecting nothing -ok -Trying: - @async - def write(data): - # append data to the datalist by locking - with threading.Lock(): - time.sleep(1) # emulate some long running operation - datalist.append(data) - # other operations not requiring a lock here + @decorator(Future) + def long_running(x): + time.sleep(.5) + return x Expecting nothing ok Trying: - write("data1") # doctest: +ELLIPSIS -Expecting: - -ok -Trying: - time.sleep(.1) # wait a bit, so we are sure data2 is written after data1 + fut1 = long_running(1) Expecting nothing ok Trying: - write("data2") # doctest: +ELLIPSIS -Expecting: - -ok -Trying: - time.sleep(2) # wait for the writers to complete + fut2 = long_running(2) Expecting nothing ok Trying: - print(datalist) + fut1.result() + fut2.result() Expecting: - ['data1', 'data2'] + 3 ok Trying: from contextlib import contextmanager @@ -244,16 +245,7 @@ Expecting nothing ok Trying: - ba = before_after('BEFORE', 'AFTER') -Expecting nothing -ok -Trying: - type(ba) -Expecting: - -ok -Trying: - with ba: + with before_after('BEFORE', 'AFTER'): print('hello') Expecting: BEFORE @@ -287,6 +279,20 @@ ok Trying: + f1 = FunctionMaker.create( + 'f1(a, b)', 'f(a, b)', dict(f=f), addsource=True, defaults=(None,)) +Expecting nothing +ok +Trying: + print(getargspec(f1)) +Expecting: + ArgSpec(args=['a', 'b'], varargs=None, varkw=None, defaults=(None,)) +ok +Trying: + import inspect +Expecting nothing +ok +Trying: print(inspect.getsource(example)) Expecting: def wrapper(*args, **kw): @@ -299,7 +305,8 @@ @tail_recursive def factorial(n, acc=1): "The good old factorial" - if n == 0: return acc + if n == 0: + return acc return factorial(n-1, n*acc) ok @@ -309,6 +316,103 @@ 24 ok Trying: + writer = XMLWriter() +Expecting nothing +ok +Trying: + writer.write(2.3) +Expecting: + '2.3' +ok +Trying: + win(Paper(), Rock()) +Expecting: + 1 +ok +Trying: + win(Scissors(), Paper()) +Expecting: + 1 +ok +Trying: + win(Rock(), Scissors()) +Expecting: + 1 +ok +Trying: + win(Paper(), Paper()) +Expecting: + 0 +ok +Trying: + win(Rock(), Rock()) +Expecting: + 0 +ok +Trying: + win(Scissors(), Scissors()) +Expecting: + 0 +ok +Trying: + win(Rock(), Paper()) +Expecting: + -1 +ok +Trying: + win(Paper(), Scissors()) +Expecting: + -1 +ok +Trying: + win(Scissors(), Rock()) +Expecting: + -1 +ok +Trying: + win(StrongRock(), Scissors()) +Expecting: + 1 +ok +Trying: + win.dispatch_info(StrongRock, Scissors) +Expecting: + [('StrongRock', 'Scissors'), ('Rock', 'Scissors')] +ok +Trying: + issubclass(WithLength, collections.Sized) +Expecting: + True +ok +Trying: + get_length(WithLength()) +Expecting: + 0 +ok +Trying: + _ = collections.Set.register(SomeSet) +Expecting nothing +ok +Trying: + issubclass(SomeSet, collections.Set) +Expecting: + True +ok +Trying: + get_length(SomeSet()) # NB: the implementation for Sized would give 0 +Expecting: + 1 +ok +Trying: + g, V = singledispatch_example2() +Expecting nothing +ok +Trying: + g.dispatch_info(V) +Expecting: + [('V',), ('Sized',), ('S',), ('Container',)] +ok +Trying: @trace def f(): 1/0 @@ -327,6 +431,19 @@ ZeroDivisionError: ... ok Trying: + @memoize + def getkeys(**kw): + return kw.keys() +Expecting nothing +ok +Trying: + getkeys(func='a') # doctest: +ELLIPSIS +Expecting: + Traceback (most recent call last): + ... + TypeError: _memoize() got multiple values for ... 'func' +ok +Trying: @trace def f(_func_): print(f) Expecting: @@ -375,7 +492,7 @@ Expecting nothing ok Trying: - a.insert() # err + a.insert() # doctest: +IGNORE_EXCEPTION_DETAIL Expecting: Traceback (most recent call last): ... @@ -419,6 +536,10 @@ Expecting nothing ok Trying: + import inspect +Expecting nothing +ok +Trying: inspect.getfullargspec(f) Expecting: FullArgSpec(args=[], varargs=None, varkw='kw', defaults=None, kwonlyargs=['a'], kwonlydefaults={'a': 1}, annotations={}) @@ -441,51 +562,72 @@ Expecting nothing ok Trying: - f.__kwdefaults__ + f.__kwdefaults__ Expecting: {'kwonly': 2} ok -31 items had no tests: - __main__.Action.delete - __main__.Action.insert - __main__.Action.view - __main__.Admin - __main__.Async - __main__.Async.__call__ - __main__.Async.__init__ - __main__.PermissionError - __main__.PowerUser - __main__.TailRecursive - __main__.TailRecursive.__call__ - __main__.TailRecursive.__init__ - __main__.User - __main__._memoize - __main__._trace - __main__.before_after - __main__.blocking - __main__.decorator_apply - __main__.example - __main__.fact - __main__.factorial - __main__.get_userclass - __main__.identity_dec - __main__.memoize - __main__.memoize_uw - __main__.on_closing - __main__.on_failure - __main__.on_success - __main__.restricted - __main__.tail_recursive - __main__.trace +52 items had no tests: + documentation.Action.delete + documentation.Action.insert + documentation.Action.view + documentation.Admin + documentation.C + documentation.Future + documentation.Future.__init__ + documentation.Future.result + documentation.Paper + documentation.PermissionError + documentation.PowerUser + documentation.Rock + documentation.Scissors + documentation.SomeSet + documentation.SomeSet.__len__ + documentation.StrongRock + documentation.TailRecursive + documentation.TailRecursive.__call__ + documentation.TailRecursive.__init__ + documentation.User + documentation.WithLength + documentation.WithLength.__len__ + documentation.XMLWriter + documentation.XMLWriter.__init__ + documentation.XMLWriter.write + documentation._memoize + documentation._trace + documentation.before_after + documentation.blocking + documentation.decorator_apply + documentation.example + documentation.f1 + documentation.fact + documentation.factorial + documentation.get_length + documentation.get_length_set + documentation.get_length_sized + documentation.get_userclass + documentation.identity_dec + documentation.memoize + documentation.memoize_uw + documentation.restricted + documentation.singledispatch_example1 + documentation.singledispatch_example2 + documentation.tail_recursive + documentation.trace + documentation.win + documentation.winPaperScissors + documentation.winRockPaper + documentation.winRockScissors + documentation.winStrongRockPaper + documentation.writefloat 8 items passed all tests: - 68 tests in __main__ - 3 tests in __main__.Action - 2 tests in __main__.a_test_for_pylons - 2 tests in __main__.hello - 2 tests in __main__.test_kwonly_no_args - 2 tests in __main__.test_kwonly_star_notation - 2 tests in __main__.test_kwonlyargs - 2 tests in __main__.test_kwonlydefaults -83 tests in 39 items. -83 passed and 0 failed. + 88 tests in documentation + 3 tests in documentation.Action + 2 tests in documentation.a_test_for_pylons + 2 tests in documentation.hello + 2 tests in documentation.test_kwonly_no_args + 3 tests in documentation.test_kwonly_star_notation + 2 tests in documentation.test_kwonlyargs + 2 tests in documentation.test_kwonlydefaults +104 tests in 60 items. +104 passed and 0 failed. Test passed.