Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
46cb1ef4
Kaydet (Commit)
46cb1ef4
authored
Haz 23, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use non-deprecated speling.
üst
d4daa871
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
44 deletions
+44
-44
test_inspect.py
Lib/test/test_inspect.py
+44
-44
No files found.
Lib/test/test_inspect.py
Dosyayı görüntüle @
46cb1ef4
...
@@ -1348,20 +1348,20 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1348,20 +1348,20 @@ class TestSignatureObject(unittest.TestCase):
S
((
po
,
pk
,
args
,
ko
,
kwargs
))
S
((
po
,
pk
,
args
,
ko
,
kwargs
))
with
self
.
assertRaisesRegex
p
(
ValueError
,
'wrong parameter order'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'wrong parameter order'
):
S
((
pk
,
po
,
args
,
ko
,
kwargs
))
S
((
pk
,
po
,
args
,
ko
,
kwargs
))
with
self
.
assertRaisesRegex
p
(
ValueError
,
'wrong parameter order'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'wrong parameter order'
):
S
((
po
,
args
,
pk
,
ko
,
kwargs
))
S
((
po
,
args
,
pk
,
ko
,
kwargs
))
with
self
.
assertRaisesRegex
p
(
ValueError
,
'wrong parameter order'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'wrong parameter order'
):
S
((
args
,
po
,
pk
,
ko
,
kwargs
))
S
((
args
,
po
,
pk
,
ko
,
kwargs
))
with
self
.
assertRaisesRegex
p
(
ValueError
,
'wrong parameter order'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'wrong parameter order'
):
S
((
po
,
pk
,
args
,
kwargs
,
ko
))
S
((
po
,
pk
,
args
,
kwargs
,
ko
))
kwargs2
=
kwargs
.
replace
(
name
=
'args'
)
kwargs2
=
kwargs
.
replace
(
name
=
'args'
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'duplicate parameter name'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'duplicate parameter name'
):
S
((
po
,
pk
,
args
,
kwargs2
,
ko
))
S
((
po
,
pk
,
args
,
kwargs2
,
ko
))
def
test_signature_immutability
(
self
):
def
test_signature_immutability
(
self
):
...
@@ -1409,24 +1409,24 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1409,24 +1409,24 @@ class TestSignatureObject(unittest.TestCase):
...
))
...
))
def
test_signature_on_builtin_function
(
self
):
def
test_signature_on_builtin_function
(
self
):
with
self
.
assertRaisesRegex
p
(
ValueError
,
'not supported by signature'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'not supported by signature'
):
inspect
.
signature
(
type
)
inspect
.
signature
(
type
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'not supported by signature'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'not supported by signature'
):
# support for 'wrapper_descriptor'
# support for 'wrapper_descriptor'
inspect
.
signature
(
type
.
__call__
)
inspect
.
signature
(
type
.
__call__
)
with
self
.
assertRaisesRegex
p
(
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__
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
with
self
.
assertRaisesRegex
(
ValueError
,
'no signature found for builtin function'
):
'no signature found for builtin function'
):
# support for 'method-wrapper'
# support for 'method-wrapper'
inspect
.
signature
(
min
)
inspect
.
signature
(
min
)
def
test_signature_on_non_function
(
self
):
def
test_signature_on_non_function
(
self
):
with
self
.
assertRaisesRegex
p
(
TypeError
,
'is not a callable object'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'is not a callable object'
):
inspect
.
signature
(
42
)
inspect
.
signature
(
42
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
'is not a Python function'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'is not a Python function'
):
inspect
.
Signature
.
from_function
(
42
)
inspect
.
Signature
.
from_function
(
42
)
def
test_signature_on_method
(
self
):
def
test_signature_on_method
(
self
):
...
@@ -1485,10 +1485,10 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1485,10 +1485,10 @@ class TestSignatureObject(unittest.TestCase):
self
.
assertEqual
(
self
.
signature
(
partial
(
test
)),
((),
...
))
self
.
assertEqual
(
self
.
signature
(
partial
(
test
)),
((),
...
))
with
self
.
assertRaisesRegex
p
(
ValueError
,
"has incorrect arguments"
):
with
self
.
assertRaisesRegex
(
ValueError
,
"has incorrect arguments"
):
inspect
.
signature
(
partial
(
test
,
1
))
inspect
.
signature
(
partial
(
test
,
1
))
with
self
.
assertRaisesRegex
p
(
ValueError
,
"has incorrect arguments"
):
with
self
.
assertRaisesRegex
(
ValueError
,
"has incorrect arguments"
):
inspect
.
signature
(
partial
(
test
,
a
=
1
))
inspect
.
signature
(
partial
(
test
,
a
=
1
))
def
test
(
a
,
b
,
*
,
c
,
d
):
def
test
(
a
,
b
,
*
,
c
,
d
):
...
@@ -1604,7 +1604,7 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1604,7 +1604,7 @@ class TestSignatureObject(unittest.TestCase):
self
.
assertEqual
(
_foo
(
c
=
10
),
(
1
,
30
,
10
))
self
.
assertEqual
(
_foo
(
c
=
10
),
(
1
,
30
,
10
))
_foo
=
partial
(
_foo
,
2
)
# now 'b' has two values -
_foo
=
partial
(
_foo
,
2
)
# now 'b' has two values -
# positional and keyword
# positional and keyword
with
self
.
assertRaisesRegex
p
(
ValueError
,
"has incorrect arguments"
):
with
self
.
assertRaisesRegex
(
ValueError
,
"has incorrect arguments"
):
inspect
.
signature
(
_foo
)
inspect
.
signature
(
_foo
)
def
foo
(
a
,
b
,
c
,
*
,
d
):
def
foo
(
a
,
b
,
c
,
*
,
d
):
...
@@ -1775,7 +1775,7 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1775,7 +1775,7 @@ class TestSignatureObject(unittest.TestCase):
class
Spam
:
class
Spam
:
pass
pass
with
self
.
assertRaisesRegex
p
(
TypeError
,
"is not a callable object"
):
with
self
.
assertRaisesRegex
(
TypeError
,
"is not a callable object"
):
inspect
.
signature
(
Spam
())
inspect
.
signature
(
Spam
())
class
Bar
(
Spam
,
Foo
):
class
Bar
(
Spam
,
Foo
):
...
@@ -1787,7 +1787,7 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1787,7 +1787,7 @@ class TestSignatureObject(unittest.TestCase):
class
ToFail
:
class
ToFail
:
__call__
=
type
__call__
=
type
with
self
.
assertRaisesRegex
p
(
ValueError
,
"not supported by signature"
):
with
self
.
assertRaisesRegex
(
ValueError
,
"not supported by signature"
):
inspect
.
signature
(
ToFail
())
inspect
.
signature
(
ToFail
())
...
@@ -1850,7 +1850,7 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1850,7 +1850,7 @@ class TestSignatureObject(unittest.TestCase):
def
test_signature_unhashable
(
self
):
def
test_signature_unhashable
(
self
):
def
foo
(
a
):
pass
def
foo
(
a
):
pass
sig
=
inspect
.
signature
(
foo
)
sig
=
inspect
.
signature
(
foo
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
'unhashable type'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'unhashable type'
):
hash
(
sig
)
hash
(
sig
)
def
test_signature_str
(
self
):
def
test_signature_str
(
self
):
...
@@ -1920,27 +1920,27 @@ class TestParameterObject(unittest.TestCase):
...
@@ -1920,27 +1920,27 @@ class TestParameterObject(unittest.TestCase):
self
.
assertIs
(
p
.
annotation
,
p
.
empty
)
self
.
assertIs
(
p
.
annotation
,
p
.
empty
)
self
.
assertEqual
(
p
.
kind
,
inspect
.
Parameter
.
POSITIONAL_ONLY
)
self
.
assertEqual
(
p
.
kind
,
inspect
.
Parameter
.
POSITIONAL_ONLY
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'invalid value'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'invalid value'
):
inspect
.
Parameter
(
'foo'
,
default
=
10
,
kind
=
'123'
)
inspect
.
Parameter
(
'foo'
,
default
=
10
,
kind
=
'123'
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'not a valid parameter name'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'not a valid parameter name'
):
inspect
.
Parameter
(
'1'
,
kind
=
inspect
.
Parameter
.
VAR_KEYWORD
)
inspect
.
Parameter
(
'1'
,
kind
=
inspect
.
Parameter
.
VAR_KEYWORD
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
with
self
.
assertRaisesRegex
(
ValueError
,
'non-positional-only parameter'
):
'non-positional-only parameter'
):
inspect
.
Parameter
(
None
,
kind
=
inspect
.
Parameter
.
VAR_KEYWORD
)
inspect
.
Parameter
(
None
,
kind
=
inspect
.
Parameter
.
VAR_KEYWORD
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'cannot have default values'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'cannot have default values'
):
inspect
.
Parameter
(
'a'
,
default
=
42
,
inspect
.
Parameter
(
'a'
,
default
=
42
,
kind
=
inspect
.
Parameter
.
VAR_KEYWORD
)
kind
=
inspect
.
Parameter
.
VAR_KEYWORD
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'cannot have default values'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'cannot have default values'
):
inspect
.
Parameter
(
'a'
,
default
=
42
,
inspect
.
Parameter
(
'a'
,
default
=
42
,
kind
=
inspect
.
Parameter
.
VAR_POSITIONAL
)
kind
=
inspect
.
Parameter
.
VAR_POSITIONAL
)
p
=
inspect
.
Parameter
(
'a'
,
default
=
42
,
p
=
inspect
.
Parameter
(
'a'
,
default
=
42
,
kind
=
inspect
.
Parameter
.
POSITIONAL_OR_KEYWORD
)
kind
=
inspect
.
Parameter
.
POSITIONAL_OR_KEYWORD
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'cannot have default values'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'cannot have default values'
):
p
.
replace
(
kind
=
inspect
.
Parameter
.
VAR_POSITIONAL
)
p
.
replace
(
kind
=
inspect
.
Parameter
.
VAR_POSITIONAL
)
self
.
assertTrue
(
repr
(
p
)
.
startswith
(
'<Parameter'
))
self
.
assertTrue
(
repr
(
p
)
.
startswith
(
'<Parameter'
))
...
@@ -1959,7 +1959,7 @@ class TestParameterObject(unittest.TestCase):
...
@@ -1959,7 +1959,7 @@ class TestParameterObject(unittest.TestCase):
p
=
inspect
.
Parameter
(
'foo'
,
default
=
42
,
p
=
inspect
.
Parameter
(
'foo'
,
default
=
42
,
kind
=
inspect
.
Parameter
.
KEYWORD_ONLY
)
kind
=
inspect
.
Parameter
.
KEYWORD_ONLY
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
'unhashable type'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'unhashable type'
):
hash
(
p
)
hash
(
p
)
def
test_signature_parameter_replace
(
self
):
def
test_signature_parameter_replace
(
self
):
...
@@ -1978,7 +1978,7 @@ class TestParameterObject(unittest.TestCase):
...
@@ -1978,7 +1978,7 @@ class TestParameterObject(unittest.TestCase):
self
.
assertEqual
(
p2
.
name
,
'bar'
)
self
.
assertEqual
(
p2
.
name
,
'bar'
)
self
.
assertNotEqual
(
p2
,
p
)
self
.
assertNotEqual
(
p2
,
p
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'not a valid parameter name'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'not a valid parameter name'
):
p2
=
p2
.
replace
(
name
=
p2
.
empty
)
p2
=
p2
.
replace
(
name
=
p2
.
empty
)
p2
=
p2
.
replace
(
name
=
'foo'
,
default
=
None
)
p2
=
p2
.
replace
(
name
=
'foo'
,
default
=
None
)
...
@@ -1993,7 +1993,7 @@ class TestParameterObject(unittest.TestCase):
...
@@ -1993,7 +1993,7 @@ class TestParameterObject(unittest.TestCase):
self
.
assertEqual
(
p2
.
kind
,
p2
.
POSITIONAL_OR_KEYWORD
)
self
.
assertEqual
(
p2
.
kind
,
p2
.
POSITIONAL_OR_KEYWORD
)
self
.
assertNotEqual
(
p2
,
p
)
self
.
assertNotEqual
(
p2
,
p
)
with
self
.
assertRaisesRegex
p
(
ValueError
,
'invalid value for'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'invalid value for'
):
p2
=
p2
.
replace
(
kind
=
p2
.
empty
)
p2
=
p2
.
replace
(
kind
=
p2
.
empty
)
p2
=
p2
.
replace
(
kind
=
p2
.
KEYWORD_ONLY
)
p2
=
p2
.
replace
(
kind
=
p2
.
KEYWORD_ONLY
)
...
@@ -2028,11 +2028,11 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -2028,11 +2028,11 @@ class TestSignatureBind(unittest.TestCase):
return
42
return
42
self
.
assertEqual
(
self
.
call
(
test
),
42
)
self
.
assertEqual
(
self
.
call
(
test
),
42
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
'too many positional arguments'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'too many positional arguments'
):
self
.
call
(
test
,
1
)
self
.
call
(
test
,
1
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
'too many positional arguments'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'too many positional arguments'
):
self
.
call
(
test
,
1
,
spam
=
10
)
self
.
call
(
test
,
1
,
spam
=
10
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
'too many keyword arguments'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'too many keyword arguments'
):
self
.
call
(
test
,
spam
=
1
)
self
.
call
(
test
,
spam
=
1
)
def
test_signature_bind_var
(
self
):
def
test_signature_bind_var
(
self
):
...
@@ -2054,13 +2054,13 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -2054,13 +2054,13 @@ class TestSignatureBind(unittest.TestCase):
self
.
assertEqual
(
self
.
call
(
test
,
1
,
2
,
3
),
(
1
,
2
,
3
))
self
.
assertEqual
(
self
.
call
(
test
,
1
,
2
,
3
),
(
1
,
2
,
3
))
with
self
.
assertRaisesRegex
p
(
TypeError
,
'too many positional arguments'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'too many positional arguments'
):
self
.
call
(
test
,
1
,
2
,
3
,
4
)
self
.
call
(
test
,
1
,
2
,
3
,
4
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
"'b' parameter lacking default"
):
with
self
.
assertRaisesRegex
(
TypeError
,
"'b' parameter lacking default"
):
self
.
call
(
test
,
1
)
self
.
call
(
test
,
1
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
"'a' parameter lacking default"
):
with
self
.
assertRaisesRegex
(
TypeError
,
"'a' parameter lacking default"
):
self
.
call
(
test
)
self
.
call
(
test
)
def
test
(
a
,
b
,
c
=
10
):
def
test
(
a
,
b
,
c
=
10
):
...
@@ -2090,7 +2090,7 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -2090,7 +2090,7 @@ class TestSignatureBind(unittest.TestCase):
self
.
assertEqual
(
self
.
call
(
test
,
b
=
1
,
a
=
2
),
(
2
,
1
,
3
,
()))
self
.
assertEqual
(
self
.
call
(
test
,
b
=
1
,
a
=
2
),
(
2
,
1
,
3
,
()))
self
.
assertEqual
(
self
.
call
(
test
,
1
,
b
=
2
),
(
1
,
2
,
3
,
()))
self
.
assertEqual
(
self
.
call
(
test
,
1
,
b
=
2
),
(
1
,
2
,
3
,
()))
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
"multiple values for argument 'c'"
):
"multiple values for argument 'c'"
):
self
.
call
(
test
,
1
,
2
,
3
,
c
=
4
)
self
.
call
(
test
,
1
,
2
,
3
,
c
=
4
)
...
@@ -2125,14 +2125,14 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -2125,14 +2125,14 @@ class TestSignatureBind(unittest.TestCase):
def
test_signature_bind_kwonly
(
self
):
def
test_signature_bind_kwonly
(
self
):
def
test
(
*
,
foo
):
def
test
(
*
,
foo
):
return
foo
return
foo
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
'too many positional arguments'
):
'too many positional arguments'
):
self
.
call
(
test
,
1
)
self
.
call
(
test
,
1
)
self
.
assertEqual
(
self
.
call
(
test
,
foo
=
1
),
1
)
self
.
assertEqual
(
self
.
call
(
test
,
foo
=
1
),
1
)
def
test
(
a
,
*
,
foo
=
1
,
bar
):
def
test
(
a
,
*
,
foo
=
1
,
bar
):
return
foo
return
foo
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
"'bar' parameter lacking default value"
):
"'bar' parameter lacking default value"
):
self
.
call
(
test
,
1
)
self
.
call
(
test
,
1
)
...
@@ -2141,23 +2141,23 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -2141,23 +2141,23 @@ class TestSignatureBind(unittest.TestCase):
self
.
assertEqual
(
self
.
call
(
test
,
1
,
bar
=
2
),
(
1
,
2
))
self
.
assertEqual
(
self
.
call
(
test
,
1
,
bar
=
2
),
(
1
,
2
))
self
.
assertEqual
(
self
.
call
(
test
,
bar
=
2
,
foo
=
1
),
(
1
,
2
))
self
.
assertEqual
(
self
.
call
(
test
,
bar
=
2
,
foo
=
1
),
(
1
,
2
))
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
'too many keyword arguments'
):
'too many keyword arguments'
):
self
.
call
(
test
,
bar
=
2
,
foo
=
1
,
spam
=
10
)
self
.
call
(
test
,
bar
=
2
,
foo
=
1
,
spam
=
10
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
'too many positional arguments'
):
'too many positional arguments'
):
self
.
call
(
test
,
1
,
2
)
self
.
call
(
test
,
1
,
2
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
'too many positional arguments'
):
'too many positional arguments'
):
self
.
call
(
test
,
1
,
2
,
bar
=
2
)
self
.
call
(
test
,
1
,
2
,
bar
=
2
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
'too many keyword arguments'
):
'too many keyword arguments'
):
self
.
call
(
test
,
1
,
bar
=
2
,
spam
=
'ham'
)
self
.
call
(
test
,
1
,
bar
=
2
,
spam
=
'ham'
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
"'bar' parameter lacking default value"
):
"'bar' parameter lacking default value"
):
self
.
call
(
test
,
1
)
self
.
call
(
test
,
1
)
...
@@ -2169,7 +2169,7 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -2169,7 +2169,7 @@ class TestSignatureBind(unittest.TestCase):
(
1
,
2
,
{
'spam'
:
'ham'
}))
(
1
,
2
,
{
'spam'
:
'ham'
}))
self
.
assertEqual
(
self
.
call
(
test
,
spam
=
'ham'
,
foo
=
1
,
bar
=
2
),
self
.
assertEqual
(
self
.
call
(
test
,
spam
=
'ham'
,
foo
=
1
,
bar
=
2
),
(
1
,
2
,
{
'spam'
:
'ham'
}))
(
1
,
2
,
{
'spam'
:
'ham'
}))
with
self
.
assertRaisesRegex
p
(
TypeError
,
with
self
.
assertRaisesRegex
(
TypeError
,
"'foo' parameter lacking default value"
):
"'foo' parameter lacking default value"
):
self
.
call
(
test
,
spam
=
'ham'
,
bar
=
2
)
self
.
call
(
test
,
spam
=
'ham'
,
bar
=
2
)
self
.
assertEqual
(
self
.
call
(
test
,
1
,
bar
=
2
,
bin
=
1
,
spam
=
10
),
self
.
assertEqual
(
self
.
call
(
test
,
1
,
bar
=
2
,
bin
=
1
,
spam
=
10
),
...
@@ -2205,10 +2205,10 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -2205,10 +2205,10 @@ class TestSignatureBind(unittest.TestCase):
self
.
assertEqual
(
self
.
call
(
test
,
1
,
2
,
4
,
5
,
bar
=
6
),
self
.
assertEqual
(
self
.
call
(
test
,
1
,
2
,
4
,
5
,
bar
=
6
),
(
1
,
2
,
4
,
5
,
6
,
{}))
(
1
,
2
,
4
,
5
,
6
,
{}))
with
self
.
assertRaisesRegex
p
(
TypeError
,
"parameter is positional only"
):
with
self
.
assertRaisesRegex
(
TypeError
,
"parameter is positional only"
):
self
.
call
(
test
,
1
,
2
,
c_po
=
4
)
self
.
call
(
test
,
1
,
2
,
c_po
=
4
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
"parameter is positional only"
):
with
self
.
assertRaisesRegex
(
TypeError
,
"parameter is positional only"
):
self
.
call
(
test
,
a_po
=
1
,
b_po
=
2
)
self
.
call
(
test
,
a_po
=
1
,
b_po
=
2
)
...
@@ -2217,7 +2217,7 @@ class TestBoundArguments(unittest.TestCase):
...
@@ -2217,7 +2217,7 @@ class TestBoundArguments(unittest.TestCase):
def
foo
(
a
):
pass
def
foo
(
a
):
pass
ba
=
inspect
.
signature
(
foo
)
.
bind
(
1
)
ba
=
inspect
.
signature
(
foo
)
.
bind
(
1
)
with
self
.
assertRaisesRegex
p
(
TypeError
,
'unhashable type'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'unhashable type'
):
hash
(
ba
)
hash
(
ba
)
def
test_signature_bound_arguments_equality
(
self
):
def
test_signature_bound_arguments_equality
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment