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
d06c201e
Kaydet (Commit)
d06c201e
authored
Mar 30, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #14904: Made test_unicode_repr_oflw to use less memory.
Corrected memory requirements in other bigmem tests.
üst
7d490650
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
34 deletions
+43
-34
test_bigmem.py
Lib/test/test_bigmem.py
+43
-34
No files found.
Lib/test/test_bigmem.py
Dosyayı görüntüle @
d06c201e
...
...
@@ -33,6 +33,11 @@ import sys
# memuse-per-size should remain sane (less than a few thousand); if your
# test uses more, adjust 'size' upward, instead.
if
test_support
.
have_unicode
:
character_size
=
4
if
sys
.
maxunicode
>
0xFFFF
else
2
else
:
character_size
=
1
class
StrTest
(
unittest
.
TestCase
):
@bigmemtest
(
minsize
=
_2G
,
memuse
=
2
)
def
test_capitalize
(
self
,
size
):
...
...
@@ -54,7 +59,8 @@ class StrTest(unittest.TestCase):
self
.
assertEqual
(
s
[
lpadsize
:
-
rpadsize
],
SUBSTR
)
self
.
assertEqual
(
s
.
strip
(),
SUBSTR
.
strip
())
@precisionbigmemtest
(
size
=
_2G
-
1
,
memuse
=
1
)
@test_support.requires_unicode
@precisionbigmemtest
(
size
=
_2G
-
1
,
memuse
=
character_size
)
def
test_center_unicode
(
self
,
size
):
SUBSTR
=
u' abc def ghi'
try
:
...
...
@@ -81,7 +87,8 @@ class StrTest(unittest.TestCase):
self
.
assertEqual
(
s
.
count
(
'i'
),
1
)
self
.
assertEqual
(
s
.
count
(
'j'
),
0
)
@bigmemtest
(
minsize
=
_2G
+
2
,
memuse
=
3
)
@test_support.requires_unicode
@bigmemtest
(
minsize
=
_2G
+
2
,
memuse
=
1
+
character_size
)
def
test_decode
(
self
,
size
):
s
=
'.'
*
size
self
.
assertEqual
(
len
(
s
.
decode
(
'utf-8'
)),
size
)
...
...
@@ -93,45 +100,30 @@ class StrTest(unittest.TestCase):
s
=
c
*
size
self
.
assertEqual
(
len
(
s
.
encode
(
enc
)),
expectedsize
)
@bigmemtest
(
minsize
=
_2G
+
2
,
memuse
=
3
)
@test_support.requires_unicode
@bigmemtest
(
minsize
=
_2G
+
2
,
memuse
=
character_size
+
4
)
def
test_encode
(
self
,
size
):
return
self
.
basic_encode_test
(
size
,
'utf-8'
)
self
.
basic_encode_test
(
size
,
'utf-8'
)
@precisionbigmemtest
(
size
=
_4G
//
6
+
2
,
memuse
=
2
)
@test_support.requires_unicode
@precisionbigmemtest
(
size
=
_4G
//
6
+
2
,
memuse
=
character_size
+
6
)
def
test_encode_raw_unicode_escape
(
self
,
size
):
try
:
return
self
.
basic_encode_test
(
size
,
'raw_unicode_escape'
)
except
MemoryError
:
pass
# acceptable on 32-bit
self
.
basic_encode_test
(
size
,
'raw_unicode_escape'
)
@precisionbigmemtest
(
size
=
_4G
//
5
+
70
,
memuse
=
3
)
@test_support.requires_unicode
@precisionbigmemtest
(
size
=
_4G
//
5
+
70
,
memuse
=
character_size
+
8
)
def
test_encode_utf7
(
self
,
size
):
try
:
return
self
.
basic_encode_test
(
size
,
'utf7'
)
except
MemoryError
:
pass
# acceptable on 32-bit
self
.
basic_encode_test
(
size
,
'utf7'
)
@precisionbigmemtest
(
size
=
_4G
//
4
+
5
,
memuse
=
6
)
@test_support.requires_unicode
@precisionbigmemtest
(
size
=
_4G
//
4
+
5
,
memuse
=
character_size
+
4
)
def
test_encode_utf32
(
self
,
size
):
try
:
return
self
.
basic_encode_test
(
size
,
'utf32'
,
expectedsize
=
4
*
size
+
4
)
except
MemoryError
:
pass
# acceptable on 32-bit
self
.
basic_encode_test
(
size
,
'utf32'
,
expectedsize
=
4
*
size
+
4
)
@test_support.requires_unicode
@precisionbigmemtest
(
size
=
_2G
-
1
,
memuse
=
4
)
def
test_decodeascii
(
self
,
size
):
return
self
.
basic_encode_test
(
size
,
'ascii'
,
c
=
'A'
)
@precisionbigmemtest
(
size
=
_4G
//
5
,
memuse
=
6
+
2
)
def
test_unicode_repr_oflw
(
self
,
size
):
self
.
skipTest
(
"test crashes - see issue #14904"
)
try
:
s
=
u"
\uAAAA
"
*
size
r
=
repr
(
s
)
except
MemoryError
:
pass
# acceptable on 32-bit
else
:
self
.
assertTrue
(
s
==
eval
(
r
))
self
.
basic_encode_test
(
size
,
'ascii'
,
c
=
'A'
)
@bigmemtest
(
minsize
=
_2G
,
memuse
=
2
)
def
test_endswith
(
self
,
size
):
...
...
@@ -516,10 +508,27 @@ class StrTest(unittest.TestCase):
self
.
assertEqual
(
s
.
count
(
'
\\
'
),
size
)
self
.
assertEqual
(
s
.
count
(
'0'
),
size
*
2
)
@bigmemtest
(
minsize
=
2
**
32
//
5
,
memuse
=
6
+
2
)
@test_support.requires_unicode
@bigmemtest
(
minsize
=
2
**
32
//
6
,
memuse
=
character_size
+
6
)
def
test_unicode_repr
(
self
,
size
):
s
=
u"
\uAAAA
"
*
size
self
.
assertTrue
(
len
(
repr
(
s
))
>
size
)
s
=
unichr
(
0xABCD
)
*
size
try
:
r
=
repr
(
s
)
self
.
assertEqual
(
len
(
r
),
3
+
6
*
size
)
self
.
assertTrue
(
r
.
endswith
(
r"\uabcd'"
),
r
[
-
10
:])
finally
:
s
=
r
=
None
@test_support.requires_unicode
@precisionbigmemtest
(
size
=
_4G
//
6
+
1
,
memuse
=
character_size
+
6
)
def
test_unicode_repr_oflw
(
self
,
size
):
s
=
unichr
(
0xABCD
)
*
size
try
:
r
=
repr
(
s
)
self
.
assertEqual
(
len
(
r
),
3
+
6
*
size
)
self
.
assertTrue
(
r
.
endswith
(
r"\uabcd'"
),
r
[
-
10
:])
finally
:
r
=
s
=
None
# This test is meaningful even with size < 2G, as long as the
# doubled string is > 2G (but it tests more if both are > 2G :)
...
...
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