summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-04-15 20:48:31 (GMT)
committerGitHub <noreply@github.com>2023-04-15 20:48:31 (GMT)
commit4fe1c4b97e39429abbb9c2117fe40f585de00887 (patch)
tree2f932080087133c813be226e76a3cf82f9e61e08
parent0097c36e07eeb516bcccba34feb4d494a67832d5 (diff)
downloadcpython-4fe1c4b97e39429abbb9c2117fe40f585de00887.zip
cpython-4fe1c4b97e39429abbb9c2117fe40f585de00887.tar.gz
cpython-4fe1c4b97e39429abbb9c2117fe40f585de00887.tar.bz2
gh-103553: Improve `test_inspect`: add more assertions, remove unused (#103554)
-rw-r--r--Lib/test/test_inspect.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index cfdb992..6b342b1 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -1820,8 +1820,7 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualException(f, '2, 3, 4')
self.assertEqualException(f, '1, 2, 3, a=1')
self.assertEqualException(f, '2, 3, 4, c=5')
- # XXX: success of this one depends on dict order
- ## self.assertEqualException(f, '2, 3, 4, a=1, c=5')
+ self.assertEqualException(f, '2, 3, 4, a=1, c=5')
# f got an unexpected keyword argument
self.assertEqualException(f, 'c=2')
self.assertEqualException(f, '2, c=3')
@@ -1832,17 +1831,19 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualException(f, '1, a=2')
self.assertEqualException(f, '1, **{"a":2}')
self.assertEqualException(f, '1, 2, b=3')
- # XXX: Python inconsistency
- # - for functions and bound methods: unexpected keyword 'c'
- # - for unbound methods: multiple values for keyword 'a'
- #self.assertEqualException(f, '1, c=3, a=2')
+ self.assertEqualException(f, '1, c=3, a=2')
# issue11256:
f3 = self.makeCallable('**c')
self.assertEqualException(f3, '1, 2')
self.assertEqualException(f3, '1, 2, a=1, b=2')
f4 = self.makeCallable('*, a, b=0')
- self.assertEqualException(f3, '1, 2')
- self.assertEqualException(f3, '1, 2, a=1, b=2')
+ self.assertEqualException(f4, '1, 2')
+ self.assertEqualException(f4, '1, 2, a=1, b=2')
+ self.assertEqualException(f4, 'a=1, a=3')
+ self.assertEqualException(f4, 'a=1, c=3')
+ self.assertEqualException(f4, 'a=1, a=3, b=4')
+ self.assertEqualException(f4, 'a=1, b=2, a=3, b=4')
+ self.assertEqualException(f4, 'a=1, a=2, a=3, b=4')
# issue #20816: getcallargs() fails to iterate over non-existent
# kwonlydefaults and raises a wrong TypeError
@@ -2872,8 +2873,6 @@ class TestSignatureObject(unittest.TestCase):
def test_signature_on_partial(self):
from functools import partial
- Parameter = inspect.Parameter
-
def test():
pass
@@ -2988,8 +2987,6 @@ class TestSignatureObject(unittest.TestCase):
((('c', ..., int, "positional_or_keyword"),),
42))
- psig = inspect.signature(partial(partial(test, 1), 2))
-
def foo(a):
return a
_foo = partial(partial(foo, a=10), a=20)
@@ -4153,8 +4150,6 @@ class TestSignatureBind(unittest.TestCase):
self.assertEqual(ba.args, (10, 20))
def test_signature_bind_positional_only(self):
- P = inspect.Parameter
-
def test(a_po, b_po, c_po=3, /, foo=42, *, bar=50, **kwargs):
return a_po, b_po, c_po, foo, bar, kwargs
@@ -4578,7 +4573,6 @@ class TestMain(unittest.TestCase):
self.assertEqual(err, b'')
def test_builtins(self):
- module = importlib.import_module('unittest')
_, out, err = assert_python_failure('-m', 'inspect',
'sys')
lines = err.decode().splitlines()