summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2014-01-27 22:28:37 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2014-01-27 22:28:37 (GMT)
commitda5fe4f2dacb1d942a2b1046a5652452414721e8 (patch)
tree4269c41161652bd3b9f06c7a1660814184f977b8 /Lib/test
parenteedf1c1ebf88a7b4762b449fee30fe3f6f518ebc (diff)
downloadcpython-da5fe4f2dacb1d942a2b1046a5652452414721e8.zip
cpython-da5fe4f2dacb1d942a2b1046a5652452414721e8.tar.gz
cpython-da5fe4f2dacb1d942a2b1046a5652452414721e8.tar.bz2
inspect.signature: Add support for 'functools.partialmethod' #20223
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_inspect.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 484e0dc..f5f18f0 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -1877,6 +1877,33 @@ class TestSignatureObject(unittest.TestCase):
ba = inspect.signature(_foo).bind(12, 14)
self.assertEqual(_foo(*ba.args, **ba.kwargs), (12, 14, 13))
+ def test_signature_on_partialmethod(self):
+ from functools import partialmethod
+
+ class Spam:
+ def test():
+ pass
+ ham = partialmethod(test)
+
+ with self.assertRaisesRegex(ValueError, "has incorrect arguments"):
+ inspect.signature(Spam.ham)
+
+ class Spam:
+ def test(it, a, *, c) -> 'spam':
+ pass
+ ham = partialmethod(test, c=1)
+
+ self.assertEqual(self.signature(Spam.ham),
+ ((('it', ..., ..., 'positional_or_keyword'),
+ ('a', ..., ..., 'positional_or_keyword'),
+ ('c', 1, ..., 'keyword_only')),
+ 'spam'))
+
+ self.assertEqual(self.signature(Spam().ham),
+ ((('a', ..., ..., 'positional_or_keyword'),
+ ('c', 1, ..., 'keyword_only')),
+ 'spam'))
+
def test_signature_on_decorated(self):
import functools