diff options
| author | Michele Simionato <michele.simionato@gmail.com> | 2015-12-09 10:19:54 +0100 |
|---|---|---|
| committer | Michele Simionato <michele.simionato@gmail.com> | 2015-12-09 10:19:54 +0100 |
| commit | 51f1f8057605df65e39649333139e7d55abfd646 (patch) | |
| tree | fbeb5a2150195b161247e764ffa09aa11f2ec0b8 /src/tests | |
| parent | f62d1193eb597c3fb9f47391452d4fbda7613546 (diff) | |
| download | python-decorator-git-51f1f8057605df65e39649333139e7d55abfd646.tar.gz | |
Added a doctest: +ELLIPSIS to fix old Python versions
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/documentation.py | 8 | ||||
| -rw-r--r-- | src/tests/test.py | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/tests/documentation.py b/src/tests/documentation.py index 69e9f4b..81409fc 100644 --- a/src/tests/documentation.py +++ b/src/tests/documentation.py @@ -1016,10 +1016,10 @@ David Goldstein and here is an example where it is manifest: >>> @memoize ... def getkeys(**kw): ... return kw.keys() - >>> getkeys(func='a') + >>> getkeys(func='a') # doctest: +ELLIPSIS Traceback (most recent call last): ... - TypeError: _memoize() got multiple values for argument 'func' + TypeError: _memoize() got multiple values for ... 'func' The error message looks really strange until you realize that the caller function `_memoize` uses `func` as first argument, @@ -1043,8 +1043,8 @@ follows: return cache[key] We have avoided the need to name the first argument, so the problem -simply disappear. This is a technique that you should keep in mind -when writing decorator for functions with keyword arguments. +simply disappears. This is a technique that you should keep in mind +when writing decorators for functions with keyword arguments. On a similar tone, there is a restriction on the names of the arguments: for instance, if try to call an argument ``_call_`` or diff --git a/src/tests/test.py b/src/tests/test.py index b01bc10..5bd34e8 100644 --- a/src/tests/test.py +++ b/src/tests/test.py @@ -89,7 +89,8 @@ class ExtraTestCase(unittest.TestCase): def func(**kw): return kw - self.assertEqual(func(f='a'), {'f': 'a'}) + # there is no confusion when passing args as a keyword argument + self.assertEqual(func(args='a'), {'args': 'a'}) # ################### test dispatch_on ############################# # # adapted from test_functools in Python 3.5 |
