summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 4f19f29..6ee2c30 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -1522,11 +1522,13 @@ class TestSignatureObject(unittest.TestCase):
self.assertEqual(str(S()), '()')
- def test(po, pk, *args, ko, **kwargs):
+ def test(po, pk, pod=42, pkd=100, *args, ko, **kwargs):
pass
sig = inspect.signature(test)
po = sig.parameters['po'].replace(kind=P.POSITIONAL_ONLY)
+ pod = sig.parameters['pod'].replace(kind=P.POSITIONAL_ONLY)
pk = sig.parameters['pk']
+ pkd = sig.parameters['pkd']
args = sig.parameters['args']
ko = sig.parameters['ko']
kwargs = sig.parameters['kwargs']
@@ -1549,6 +1551,15 @@ class TestSignatureObject(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'duplicate parameter name'):
S((po, pk, args, kwargs2, ko))
+ with self.assertRaisesRegex(ValueError, 'follows default argument'):
+ S((pod, po))
+
+ with self.assertRaisesRegex(ValueError, 'follows default argument'):
+ S((po, pkd, pk))
+
+ with self.assertRaisesRegex(ValueError, 'follows default argument'):
+ S((pkd, pk))
+
def test_signature_immutability(self):
def test(a):
pass