[Python-checkins] gh-103553: Improve `test_inspect`: add more assertions, remove unused (GH-103554)
miss-islington
webhook-mailer at python.org
Sat Apr 15 17:15:52 EDT 2023
https://github.com/python/cpython/commit/9f3f109dd2061159ca15552ede52c2d9b452293a
commit: 9f3f109dd2061159ca15552ede52c2d9b452293a
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-04-15T14:15:45-07:00
summary:
gh-103553: Improve `test_inspect`: add more assertions, remove unused (GH-103554)
(cherry picked from commit 4fe1c4b97e39429abbb9c2117fe40f585de00887)
Co-authored-by: Nikita Sobolev <mail at sobolevn.me>
files:
M Lib/test/test_inspect.py
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index a6507c7386a2..9f597e295445 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -1761,8 +1761,7 @@ def test_errors(self):
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')
@@ -1773,17 +1772,19 @@ def test_errors(self):
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
@@ -2710,8 +2711,6 @@ def foo(cls, *, arg):
def test_signature_on_partial(self):
from functools import partial
- Parameter = inspect.Parameter
-
def test():
pass
@@ -2826,8 +2825,6 @@ def test(a, b, c:int) -> 42:
((('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)
@@ -3958,8 +3955,6 @@ def test(a, *args, b, z=100, **kwargs):
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
@@ -4392,7 +4387,6 @@ def test_qualname_source(self):
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()
More information about the Python-checkins
mailing list