Fix inspect.signature tests for builtins when docstrings are compiled out.
This commit is contained in:
parent
3b7b1e533e
commit
fcafe43320
|
@ -9,6 +9,7 @@ import sys
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
from test import support
|
from test import support
|
||||||
|
from test.support import MISSING_C_DOCSTRINGS
|
||||||
try:
|
try:
|
||||||
import _posixsubprocess
|
import _posixsubprocess
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -109,6 +110,8 @@ class CAPITest(unittest.TestCase):
|
||||||
self.assertRaises(TypeError, _posixsubprocess.fork_exec,
|
self.assertRaises(TypeError, _posixsubprocess.fork_exec,
|
||||||
Z(),[b'1'],3,[1, 2],5,6,7,8,9,10,11,12,13,14,15,16,17)
|
Z(),[b'1'],3,[1, 2],5,6,7,8,9,10,11,12,13,14,15,16,17)
|
||||||
|
|
||||||
|
@unittest.skipIf(MISSING_C_DOCSTRINGS,
|
||||||
|
"Signature information for builtins requires docstrings")
|
||||||
def test_docstring_signature_parsing(self):
|
def test_docstring_signature_parsing(self):
|
||||||
|
|
||||||
self.assertEqual(_testcapi.no_docstring.__doc__, None)
|
self.assertEqual(_testcapi.no_docstring.__doc__, None)
|
||||||
|
|
|
@ -17,6 +17,7 @@ except ImportError:
|
||||||
ThreadPoolExecutor = None
|
ThreadPoolExecutor = None
|
||||||
|
|
||||||
from test.support import run_unittest, TESTFN, DirsOnSysPath
|
from test.support import run_unittest, TESTFN, DirsOnSysPath
|
||||||
|
from test.support import MISSING_C_DOCSTRINGS
|
||||||
from test.script_helper import assert_python_ok, assert_python_failure
|
from test.script_helper import assert_python_ok, assert_python_failure
|
||||||
from test import inspect_fodder as mod
|
from test import inspect_fodder as mod
|
||||||
from test import inspect_fodder2 as mod2
|
from test import inspect_fodder2 as mod2
|
||||||
|
@ -1579,7 +1580,7 @@ class TestSignatureObject(unittest.TestCase):
|
||||||
('kwargs', ..., int, "var_keyword")),
|
('kwargs', ..., int, "var_keyword")),
|
||||||
...))
|
...))
|
||||||
|
|
||||||
def test_signature_on_builtin_function(self):
|
def test_signature_on_unsupported_builtins(self):
|
||||||
with self.assertRaisesRegex(ValueError, 'not supported by signature'):
|
with self.assertRaisesRegex(ValueError, 'not supported by signature'):
|
||||||
inspect.signature(type)
|
inspect.signature(type)
|
||||||
with self.assertRaisesRegex(ValueError, 'not supported by signature'):
|
with self.assertRaisesRegex(ValueError, 'not supported by signature'):
|
||||||
|
@ -1588,6 +1589,10 @@ class TestSignatureObject(unittest.TestCase):
|
||||||
with self.assertRaisesRegex(ValueError, 'not supported by signature'):
|
with self.assertRaisesRegex(ValueError, 'not supported by signature'):
|
||||||
# support for 'method-wrapper'
|
# support for 'method-wrapper'
|
||||||
inspect.signature(min.__call__)
|
inspect.signature(min.__call__)
|
||||||
|
|
||||||
|
@unittest.skipIf(MISSING_C_DOCSTRINGS,
|
||||||
|
"Signature information for builtins requires docstrings")
|
||||||
|
def test_signature_on_builtins(self):
|
||||||
self.assertEqual(inspect.signature(min), None)
|
self.assertEqual(inspect.signature(min), None)
|
||||||
signature = inspect.signature(os.stat)
|
signature = inspect.signature(os.stat)
|
||||||
self.assertTrue(isinstance(signature, inspect.Signature))
|
self.assertTrue(isinstance(signature, inspect.Signature))
|
||||||
|
|
Loading…
Reference in New Issue