summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2021-04-14 06:09:12 +0200
committerMichele Simionato <michele.simionato@gmail.com>2021-04-14 06:09:12 +0200
commit187ef55dda5904505b669361e4f86f4f8b74b9e3 (patch)
treed056eca4c9dd1ba438fdbf0f3b37bd6b1dae731d /src/tests
parentc8fed191b3133bdb3021c531e5cc9dada1953a7d (diff)
downloadpython-decorator-git-187ef55dda5904505b669361e4f86f4f8b74b9e3.tar.gz
Restored apply_defaults
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/tests/test.py b/src/tests/test.py
index c10757d..acdaf93 100644
--- a/src/tests/test.py
+++ b/src/tests/test.py
@@ -6,7 +6,10 @@ import inspect
from asyncio import get_event_loop
from collections import defaultdict, ChainMap, abc as c
from decorator import dispatch_on, contextmanager, decorator
-import documentation as doc
+try:
+ from . import documentation as doc # good with pytest
+except ImportError:
+ import documentation as doc # good with `python src/tests/test.py`
@contextmanager
@@ -71,7 +74,7 @@ class DocumentationTestCase(unittest.TestCase):
def test_copy_dunder_attrs(self):
traced = doc.trace(doc.foo)
- self.assertEqual(traced.__module__, 'documentation')
+ self.assertIn('documentation', traced.__module__)
self.assertEqual(traced.__annotations__, {})
self.assertEqual(traced.__defaults__, (None,))
@@ -167,6 +170,19 @@ class ExtraTestCase(unittest.TestCase):
return x
self.assertEqual(add(f, 2)(0), 2)
+ def test_dan_schult(self):
+ # see https://github.com/micheles/decorator/issues/120
+ @decorator
+ def prnt(func, index=0, *args, **kw):
+ print(args[index])
+ return func(*args, **kw)
+
+ @prnt(index=2) # print the value of the third argument
+ def f(a, b, c=None):
+ return [a, b, c]
+
+ self.assertEqual(f(0, 1), [0, 1, None])
+
# ################### test dispatch_on ############################# #
# adapted from test_functools in Python 3.5