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
2b168443
Kaydet (Commit)
2b168443
authored
Tem 29, 2012
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #15467: Merge 3.2
üst
5ee98924
33f79972
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
46 deletions
+49
-46
support.py
Lib/test/support.py
+28
-0
test_struct.py
Lib/test/test_struct.py
+10
-30
test_sys.py
Lib/test/test_sys.py
+0
-0
test_xml_etree_c.py
Lib/test/test_xml_etree_c.py
+8
-16
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/support.py
Dosyayı görüntüle @
2b168443
...
...
@@ -25,6 +25,7 @@ import fnmatch
import
logging.handlers
import
struct
import
tempfile
import
_testcapi
try
:
import
_thread
,
threading
...
...
@@ -1082,6 +1083,33 @@ def python_is_optimized():
return
final_opt
!=
''
and
final_opt
!=
'-O0'
_header
=
'nP'
_align
=
'0n'
if
hasattr
(
sys
,
"gettotalrefcount"
):
_header
=
'2P'
+
_header
_align
=
'0P'
_vheader
=
_header
+
'n'
def
calcobjsize
(
fmt
):
return
struct
.
calcsize
(
_header
+
fmt
+
_align
)
def
calcvobjsize
(
fmt
):
return
struct
.
calcsize
(
_vheader
+
fmt
+
_align
)
_TPFLAGS_HAVE_GC
=
1
<<
14
_TPFLAGS_HEAPTYPE
=
1
<<
9
def
check_sizeof
(
test
,
o
,
size
):
result
=
sys
.
getsizeof
(
o
)
# add GC header size
if
((
type
(
o
)
==
type
)
and
(
o
.
__flags__
&
_TPFLAGS_HEAPTYPE
)
or
\
((
type
(
o
)
!=
type
)
and
(
type
(
o
)
.
__flags__
&
_TPFLAGS_HAVE_GC
))):
size
+=
_testcapi
.
SIZEOF_PYGC_HEAD
msg
=
'wrong size for
%
s: got
%
d, expected
%
d'
\
%
(
type
(
o
),
result
,
size
)
test
.
assertEqual
(
result
,
size
,
msg
)
#=======================================================================
# Decorator for running a function in a different locale, correctly resetting
# it afterwards.
...
...
Lib/test/test_struct.py
Dosyayı görüntüle @
2b168443
...
...
@@ -3,7 +3,7 @@ import unittest
import
struct
import
sys
from
test
.support
import
run_unittest
,
cpython_only
from
test
import
support
ISBIGENDIAN
=
sys
.
byteorder
==
"big"
IS32BIT
=
sys
.
maxsize
==
0x7fffffff
...
...
@@ -40,33 +40,6 @@ def bigendian_to_native(value):
return
string_reverse
(
value
)
class
StructTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
# due to missing size_t information from struct, it is assumed that
# sizeof(Py_ssize_t) = sizeof(void*)
self
.
header
=
'PP'
if
hasattr
(
sys
,
"gettotalrefcount"
):
self
.
header
+=
'2P'
def
check_sizeof
(
self
,
format_str
,
number_of_codes
):
def
size
(
fmt
):
"""Wrapper around struct.calcsize which enforces the alignment
of the end of a structure to the alignment requirement of pointer.
Note: This wrapper should only be used if a pointer member is
included and no member with a size larger than a pointer exists.
"""
return
struct
.
calcsize
(
fmt
+
'0P'
)
struct_obj
=
struct
.
Struct
(
format_str
)
# The size of 'PyStructObject'
totalsize
=
size
(
self
.
header
+
'5P'
)
# The size taken up by the 'formatcode' dynamic array
totalsize
+=
size
(
'3P'
)
*
(
number_of_codes
+
1
)
result
=
sys
.
getsizeof
(
struct_obj
)
msg
=
'wrong size for
%
s: got
%
d, expected
%
d'
\
%
(
type
(
struct_obj
),
result
,
totalsize
)
self
.
assertEqual
(
result
,
totalsize
,
msg
)
def
test_isbigendian
(
self
):
self
.
assertEqual
((
struct
.
pack
(
'=i'
,
1
)[
0
]
==
0
),
ISBIGENDIAN
)
...
...
@@ -599,7 +572,14 @@ class StructTest(unittest.TestCase):
s
=
struct
.
Struct
(
'i'
)
s
.
__init__
(
'ii'
)
@cpython_only
def
check_sizeof
(
self
,
format_str
,
number_of_codes
):
# The size of 'PyStructObject'
totalsize
=
support
.
calcobjsize
(
'2n3P'
)
# The size taken up by the 'formatcode' dynamic array
totalsize
+=
struct
.
calcsize
(
'P2n0P'
)
*
(
number_of_codes
+
1
)
support
.
check_sizeof
(
self
,
struct
.
Struct
(
format_str
),
totalsize
)
@support.cpython_only
def
test__sizeof__
(
self
):
for
code
in
integer_codes
:
self
.
check_sizeof
(
code
,
1
)
...
...
@@ -614,7 +594,7 @@ class StructTest(unittest.TestCase):
self
.
check_sizeof
(
'0c'
,
0
)
def
test_main
():
run_unittest
(
StructTest
)
support
.
run_unittest
(
StructTest
)
if
__name__
==
'__main__'
:
test_main
()
Lib/test/test_sys.py
Dosyayı görüntüle @
2b168443
This diff is collapsed.
Click to expand it.
Lib/test/test_xml_etree_c.py
Dosyayı görüntüle @
2b168443
...
...
@@ -41,38 +41,30 @@ class TestAcceleratorImported(unittest.TestCase):
@unittest.skipUnless
(
cET
,
'requires _elementtree'
)
@support.cpython_only
class
SizeofTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
import
_testcapi
gc_headsize
=
_testcapi
.
SIZEOF_PYGC_HEAD
# object header
header
=
'PP'
if
hasattr
(
sys
,
"gettotalrefcount"
):
# debug header
header
=
'PP'
+
header
# fields
element
=
header
+
'5P'
self
.
elementsize
=
gc_headsize
+
struct
.
calcsize
(
element
)
self
.
elementsize
=
support
.
calcobjsize
(
'5P'
)
# extra
self
.
extra
=
struct
.
calcsize
(
'PiiP4P'
)
check_sizeof
=
support
.
check_sizeof
def
test_element
(
self
):
e
=
cET
.
Element
(
'a'
)
self
.
assertEqual
(
sys
.
getsizeof
(
e
)
,
self
.
elementsize
)
self
.
check_sizeof
(
e
,
self
.
elementsize
)
def
test_element_with_attrib
(
self
):
e
=
cET
.
Element
(
'a'
,
href
=
'about:'
)
self
.
assertEqual
(
sys
.
getsizeof
(
e
),
self
.
elementsize
+
self
.
extra
)
self
.
check_sizeof
(
e
,
self
.
elementsize
+
self
.
extra
)
def
test_element_with_children
(
self
):
e
=
cET
.
Element
(
'a'
)
for
i
in
range
(
5
):
cET
.
SubElement
(
e
,
'span'
)
# should have space for 8 children now
self
.
assertEqual
(
sys
.
getsizeof
(
e
),
self
.
elementsize
+
self
.
extra
+
struct
.
calcsize
(
'8P'
))
self
.
check_sizeof
(
e
,
self
.
elementsize
+
self
.
extra
+
struct
.
calcsize
(
'8P'
))
def
test_main
():
from
test
import
test_xml_etree
,
test_xml_etree_c
...
...
Misc/NEWS
Dosyayı görüntüle @
2b168443
...
...
@@ -238,6 +238,9 @@ Documentation
Tests
-----
-
Issue
#
15467
:
Move
helpers
for
__sizeof__
tests
into
test_support
.
Patch
by
Serhiy
Storchaka
.
-
Issue
#
15320
:
Make
iterating
the
list
of
tests
thread
-
safe
when
running
tests
in
multiprocess
mode
.
Patch
by
Chris
Jerdonek
.
...
...
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