Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4fe1c4b

Browse files
authored
pythongh-103553: Improvetest_inspect: add more assertions, remove unused (python#103554)
1 parent0097c36 commit4fe1c4b

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

‎Lib/test/test_inspect.py‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,8 +1820,7 @@ def test_errors(self):
18201820
self.assertEqualException(f,'2, 3, 4')
18211821
self.assertEqualException(f,'1, 2, 3, a=1')
18221822
self.assertEqualException(f,'2, 3, 4, c=5')
1823-
# XXX: success of this one depends on dict order
1824-
## self.assertEqualException(f, '2, 3, 4, a=1, c=5')
1823+
self.assertEqualException(f,'2, 3, 4, a=1, c=5')
18251824
# f got an unexpected keyword argument
18261825
self.assertEqualException(f,'c=2')
18271826
self.assertEqualException(f,'2, c=3')
@@ -1832,17 +1831,19 @@ def test_errors(self):
18321831
self.assertEqualException(f,'1, a=2')
18331832
self.assertEqualException(f,'1, **{"a":2}')
18341833
self.assertEqualException(f,'1, 2, b=3')
1835-
# XXX: Python inconsistency
1836-
# - for functions and bound methods: unexpected keyword 'c'
1837-
# - for unbound methods: multiple values for keyword 'a'
1838-
#self.assertEqualException(f, '1, c=3, a=2')
1834+
self.assertEqualException(f,'1, c=3, a=2')
18391835
# issue11256:
18401836
f3=self.makeCallable('**c')
18411837
self.assertEqualException(f3,'1, 2')
18421838
self.assertEqualException(f3,'1, 2, a=1, b=2')
18431839
f4=self.makeCallable('*, a, b=0')
1844-
self.assertEqualException(f3,'1, 2')
1845-
self.assertEqualException(f3,'1, 2, a=1, b=2')
1840+
self.assertEqualException(f4,'1, 2')
1841+
self.assertEqualException(f4,'1, 2, a=1, b=2')
1842+
self.assertEqualException(f4,'a=1, a=3')
1843+
self.assertEqualException(f4,'a=1, c=3')
1844+
self.assertEqualException(f4,'a=1, a=3, b=4')
1845+
self.assertEqualException(f4,'a=1, b=2, a=3, b=4')
1846+
self.assertEqualException(f4,'a=1, a=2, a=3, b=4')
18461847

18471848
# issue #20816: getcallargs() fails to iterate over non-existent
18481849
# kwonlydefaults and raises a wrong TypeError
@@ -2872,8 +2873,6 @@ def foo(cls, *, arg):
28722873
deftest_signature_on_partial(self):
28732874
fromfunctoolsimportpartial
28742875

2875-
Parameter=inspect.Parameter
2876-
28772876
deftest():
28782877
pass
28792878

@@ -2988,8 +2987,6 @@ def test(a, b, c:int) -> 42:
29882987
((('c', ...,int,"positional_or_keyword"),),
29892988
42))
29902989

2991-
psig=inspect.signature(partial(partial(test,1),2))
2992-
29932990
deffoo(a):
29942991
returna
29952992
_foo=partial(partial(foo,a=10),a=20)
@@ -4153,8 +4150,6 @@ def test(a, *args, b, z=100, **kwargs):
41534150
self.assertEqual(ba.args, (10,20))
41544151

41554152
deftest_signature_bind_positional_only(self):
4156-
P=inspect.Parameter
4157-
41584153
deftest(a_po,b_po,c_po=3,/,foo=42,*,bar=50,**kwargs):
41594154
returna_po,b_po,c_po,foo,bar,kwargs
41604155

@@ -4578,7 +4573,6 @@ def test_qualname_source(self):
45784573
self.assertEqual(err,b'')
45794574

45804575
deftest_builtins(self):
4581-
module=importlib.import_module('unittest')
45824576
_,out,err=assert_python_failure('-m','inspect',
45834577
'sys')
45844578
lines=err.decode().splitlines()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp