summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2014-01-07 19:53:01 (GMT)
committerLarry Hastings <larry@hastings.org>2014-01-07 19:53:01 (GMT)
commit16c5191ab3443aa5c1f835848514f94c696a8c4d (patch)
treea064b4a173dddc48b34bc48b95601809c3bf9ba7 /Lib/test/test_inspect.py
parent0bce6e746274980fb934ee8f2a06cbf8f8a54e3e (diff)
downloadcpython-16c5191ab3443aa5c1f835848514f94c696a8c4d.zip
cpython-16c5191ab3443aa5c1f835848514f94c696a8c4d.tar.gz
cpython-16c5191ab3443aa5c1f835848514f94c696a8c4d.tar.bz2
Issue #20144: Argument Clinic now supports simple constants as parameter
default values. inspect.Signature correspondingly supports them in __text_signature__ fields for builtins.
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 520bf0e..9dc5475 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -15,6 +15,7 @@ try:
from concurrent.futures import ThreadPoolExecutor
except ImportError:
ThreadPoolExecutor = None
+import _testcapi
from test.support import run_unittest, TESTFN, DirsOnSysPath
from test.support import MISSING_C_DOCSTRINGS
@@ -1593,9 +1594,19 @@ class TestSignatureObject(unittest.TestCase):
@unittest.skipIf(MISSING_C_DOCSTRINGS,
"Signature information for builtins requires docstrings")
def test_signature_on_builtins(self):
+ # min doesn't have a signature (yet)
self.assertEqual(inspect.signature(min), None)
- signature = inspect.signature(os.stat)
+
+ signature = inspect.signature(_testcapi.docstring_with_signature_with_defaults)
self.assertTrue(isinstance(signature, inspect.Signature))
+ def p(name): return signature.parameters[name].default
+ self.assertEqual(p('s'), 'avocado')
+ self.assertEqual(p('d'), 3.14)
+ self.assertEqual(p('i'), 35)
+ self.assertEqual(p('c'), sys.maxsize)
+ self.assertEqual(p('n'), None)
+ self.assertEqual(p('t'), True)
+ self.assertEqual(p('f'), False)
def test_signature_on_non_function(self):
with self.assertRaisesRegex(TypeError, 'is not a callable object'):