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
acef5de6
Kaydet (Commit)
acef5de6
authored
May 16, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Backported tests for issue #18531.
üst
af7cf6d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
test_getargs2.py
Lib/test/test_getargs2.py
+56
-0
_testcapimodule.c
Modules/_testcapimodule.c
+22
-0
No files found.
Lib/test/test_getargs2.py
Dosyayı görüntüle @
acef5de6
...
...
@@ -70,6 +70,12 @@ class BadInt3(int):
def
__int__
(
self
):
return
True
class
TupleSubclass
(
tuple
):
pass
class
DictSubclass
(
dict
):
pass
class
Unsigned_TestCase
(
unittest
.
TestCase
):
def
test_b
(
self
):
...
...
@@ -321,6 +327,33 @@ class Boolean_TestCase(unittest.TestCase):
class
Tuple_TestCase
(
unittest
.
TestCase
):
def
test_args
(
self
):
from
_testcapi
import
get_args
ret
=
get_args
(
1
,
2
)
self
.
assertEqual
(
ret
,
(
1
,
2
))
self
.
assertIs
(
type
(
ret
),
tuple
)
ret
=
get_args
(
1
,
*
(
2
,
3
))
self
.
assertEqual
(
ret
,
(
1
,
2
,
3
))
self
.
assertIs
(
type
(
ret
),
tuple
)
ret
=
get_args
(
*
[
1
,
2
])
self
.
assertEqual
(
ret
,
(
1
,
2
))
self
.
assertIs
(
type
(
ret
),
tuple
)
ret
=
get_args
(
*
TupleSubclass
([
1
,
2
]))
self
.
assertEqual
(
ret
,
(
1
,
2
))
self
.
assertIsInstance
(
ret
,
tuple
)
ret
=
get_args
()
self
.
assertIn
(
ret
,
((),
None
))
self
.
assertIn
(
type
(
ret
),
(
tuple
,
type
(
None
)))
ret
=
get_args
(
*
())
self
.
assertIn
(
ret
,
((),
None
))
self
.
assertIn
(
type
(
ret
),
(
tuple
,
type
(
None
)))
def
test_tuple
(
self
):
from
_testcapi
import
getargs_tuple
...
...
@@ -336,6 +369,29 @@ class Tuple_TestCase(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
getargs_tuple
,
1
,
seq
())
class
Keywords_TestCase
(
unittest
.
TestCase
):
def
test_kwargs
(
self
):
from
_testcapi
import
get_kwargs
ret
=
get_kwargs
(
a
=
1
,
b
=
2
)
self
.
assertEqual
(
ret
,
{
'a'
:
1
,
'b'
:
2
})
self
.
assertIs
(
type
(
ret
),
dict
)
ret
=
get_kwargs
(
a
=
1
,
**
{
'b'
:
2
,
'c'
:
3
})
self
.
assertEqual
(
ret
,
{
'a'
:
1
,
'b'
:
2
,
'c'
:
3
})
self
.
assertIs
(
type
(
ret
),
dict
)
ret
=
get_kwargs
(
**
DictSubclass
({
'a'
:
1
,
'b'
:
2
}))
self
.
assertEqual
(
ret
,
{
'a'
:
1
,
'b'
:
2
})
self
.
assertIsInstance
(
ret
,
dict
)
ret
=
get_kwargs
()
self
.
assertIn
(
ret
,
({},
None
))
self
.
assertIn
(
type
(
ret
),
(
dict
,
type
(
None
)))
ret
=
get_kwargs
(
**
{})
self
.
assertIn
(
ret
,
({},
None
))
self
.
assertIn
(
type
(
ret
),
(
dict
,
type
(
None
)))
def
test_positional_args
(
self
):
# using all positional args
self
.
assertEqual
(
...
...
Modules/_testcapimodule.c
Dosyayı görüntüle @
acef5de6
...
...
@@ -872,6 +872,26 @@ test_L_code(PyObject *self)
#endif
/* ifdef HAVE_LONG_LONG */
static
PyObject
*
get_args
(
PyObject
*
self
,
PyObject
*
args
)
{
if
(
args
==
NULL
)
{
args
=
Py_None
;
}
Py_INCREF
(
args
);
return
args
;
}
static
PyObject
*
get_kwargs
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
if
(
kwargs
==
NULL
)
{
kwargs
=
Py_None
;
}
Py_INCREF
(
kwargs
);
return
kwargs
;
}
/* Test tuple argument processing */
static
PyObject
*
getargs_tuple
(
PyObject
*
self
,
PyObject
*
args
)
...
...
@@ -3651,6 +3671,8 @@ static PyMethodDef TestMethods[] = {
{
"test_pep3118_obsolete_write_locks"
,
(
PyCFunction
)
test_pep3118_obsolete_write_locks
,
METH_NOARGS
},
#endif
{
"getbuffer_with_null_view"
,
getbuffer_with_null_view
,
METH_O
},
{
"get_args"
,
get_args
,
METH_VARARGS
},
{
"get_kwargs"
,
(
PyCFunction
)
get_kwargs
,
METH_VARARGS
|
METH_KEYWORDS
},
{
"getargs_tuple"
,
getargs_tuple
,
METH_VARARGS
},
{
"getargs_keywords"
,
(
PyCFunction
)
getargs_keywords
,
METH_VARARGS
|
METH_KEYWORDS
},
...
...
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