From fcafe433202300bfba33bfe16c7b48489fca59ac Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Sat, 23 Nov 2013 17:35:48 -0800 Subject: Fix inspect.signature tests for builtins when docstrings are compiled out. --- Lib/test/test_capi.py | 3 +++ Lib/test/test_inspect.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 6f75b77..22c8eb0 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -9,6 +9,7 @@ import sys import time import unittest from test import support +from test.support import MISSING_C_DOCSTRINGS try: import _posixsubprocess except ImportError: @@ -109,6 +110,8 @@ class CAPITest(unittest.TestCase): 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) + @unittest.skipIf(MISSING_C_DOCSTRINGS, + "Signature information for builtins requires docstrings") def test_docstring_signature_parsing(self): self.assertEqual(_testcapi.no_docstring.__doc__, None) diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 0258d3df..365f592 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -17,6 +17,7 @@ except ImportError: ThreadPoolExecutor = None 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 import inspect_fodder as mod from test import inspect_fodder2 as mod2 @@ -1579,7 +1580,7 @@ class TestSignatureObject(unittest.TestCase): ('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'): inspect.signature(type) with self.assertRaisesRegex(ValueError, 'not supported by signature'): @@ -1588,6 +1589,10 @@ class TestSignatureObject(unittest.TestCase): with self.assertRaisesRegex(ValueError, 'not supported by signature'): # support for 'method-wrapper' 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) signature = inspect.signature(os.stat) self.assertTrue(isinstance(signature, inspect.Signature)) -- cgit v0.12