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
63b5b6fd
Kaydet (Commit)
63b5b6fd
authored
Eki 02, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Moved Unicode C API related tests to separate test class.
üst
480b0692
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
114 deletions
+117
-114
test_unicode.py
Lib/test/test_unicode.py
+117
-114
No files found.
Lib/test/test_unicode.py
Dosyayı görüntüle @
63b5b6fd
...
@@ -2275,6 +2275,123 @@ class UnicodeTest(string_tests.CommonTest,
...
@@ -2275,6 +2275,123 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
"
%
s"
%
s
,
'__str__ overridden'
)
self
.
assertEqual
(
"
%
s"
%
s
,
'__str__ overridden'
)
self
.
assertEqual
(
"{}"
.
format
(
s
),
'__str__ overridden'
)
self
.
assertEqual
(
"{}"
.
format
(
s
),
'__str__ overridden'
)
def
test_subclass_add
(
self
):
class
S
(
str
):
def
__add__
(
self
,
o
):
return
"3"
self
.
assertEqual
(
S
(
"4"
)
+
S
(
"5"
),
"3"
)
class
S
(
str
):
def
__iadd__
(
self
,
o
):
return
"3"
s
=
S
(
"1"
)
s
+=
"4"
self
.
assertEqual
(
s
,
"3"
)
def
test_getnewargs
(
self
):
text
=
'abc'
args
=
text
.
__getnewargs__
()
self
.
assertIsNot
(
args
[
0
],
text
)
self
.
assertEqual
(
args
[
0
],
text
)
self
.
assertEqual
(
len
(
args
),
1
)
def
test_resize
(
self
):
for
length
in
range
(
1
,
100
,
7
):
# generate a fresh string (refcount=1)
text
=
'a'
*
length
+
'b'
with
support
.
check_warnings
((
'unicode_internal codec has been '
'deprecated'
,
DeprecationWarning
)):
# fill wstr internal field
abc
=
text
.
encode
(
'unicode_internal'
)
self
.
assertEqual
(
abc
.
decode
(
'unicode_internal'
),
text
)
# resize text: wstr field must be cleared and then recomputed
text
+=
'c'
abcdef
=
text
.
encode
(
'unicode_internal'
)
self
.
assertNotEqual
(
abc
,
abcdef
)
self
.
assertEqual
(
abcdef
.
decode
(
'unicode_internal'
),
text
)
def
test_compare
(
self
):
# Issue #17615
N
=
10
ascii
=
'a'
*
N
ascii2
=
'z'
*
N
latin
=
'
\x80
'
*
N
latin2
=
'
\xff
'
*
N
bmp
=
'
\u0100
'
*
N
bmp2
=
'
\uffff
'
*
N
astral
=
'
\U00100000
'
*
N
astral2
=
'
\U0010ffff
'
*
N
strings
=
(
ascii
,
ascii2
,
latin
,
latin2
,
bmp
,
bmp2
,
astral
,
astral2
)
for
text1
,
text2
in
itertools
.
combinations
(
strings
,
2
):
equal
=
(
text1
is
text2
)
self
.
assertEqual
(
text1
==
text2
,
equal
)
self
.
assertEqual
(
text1
!=
text2
,
not
equal
)
if
equal
:
self
.
assertTrue
(
text1
<=
text2
)
self
.
assertTrue
(
text1
>=
text2
)
# text1 is text2: duplicate strings to skip the "str1 == str2"
# optimization in unicode_compare_eq() and really compare
# character per character
copy1
=
duplicate_string
(
text1
)
copy2
=
duplicate_string
(
text2
)
self
.
assertIsNot
(
copy1
,
copy2
)
self
.
assertTrue
(
copy1
==
copy2
)
self
.
assertFalse
(
copy1
!=
copy2
)
self
.
assertTrue
(
copy1
<=
copy2
)
self
.
assertTrue
(
copy2
>=
copy2
)
self
.
assertTrue
(
ascii
<
ascii2
)
self
.
assertTrue
(
ascii
<
latin
)
self
.
assertTrue
(
ascii
<
bmp
)
self
.
assertTrue
(
ascii
<
astral
)
self
.
assertFalse
(
ascii
>=
ascii2
)
self
.
assertFalse
(
ascii
>=
latin
)
self
.
assertFalse
(
ascii
>=
bmp
)
self
.
assertFalse
(
ascii
>=
astral
)
self
.
assertFalse
(
latin
<
ascii
)
self
.
assertTrue
(
latin
<
latin2
)
self
.
assertTrue
(
latin
<
bmp
)
self
.
assertTrue
(
latin
<
astral
)
self
.
assertTrue
(
latin
>=
ascii
)
self
.
assertFalse
(
latin
>=
latin2
)
self
.
assertFalse
(
latin
>=
bmp
)
self
.
assertFalse
(
latin
>=
astral
)
self
.
assertFalse
(
bmp
<
ascii
)
self
.
assertFalse
(
bmp
<
latin
)
self
.
assertTrue
(
bmp
<
bmp2
)
self
.
assertTrue
(
bmp
<
astral
)
self
.
assertTrue
(
bmp
>=
ascii
)
self
.
assertTrue
(
bmp
>=
latin
)
self
.
assertFalse
(
bmp
>=
bmp2
)
self
.
assertFalse
(
bmp
>=
astral
)
self
.
assertFalse
(
astral
<
ascii
)
self
.
assertFalse
(
astral
<
latin
)
self
.
assertFalse
(
astral
<
bmp2
)
self
.
assertTrue
(
astral
<
astral2
)
self
.
assertTrue
(
astral
>=
ascii
)
self
.
assertTrue
(
astral
>=
latin
)
self
.
assertTrue
(
astral
>=
bmp2
)
self
.
assertFalse
(
astral
>=
astral2
)
def
test_free_after_iterating
(
self
):
support
.
check_free_after_iterating
(
self
,
iter
,
str
)
support
.
check_free_after_iterating
(
self
,
reversed
,
str
)
class
CAPITest
(
unittest
.
TestCase
):
# Test PyUnicode_FromFormat()
# Test PyUnicode_FromFormat()
def
test_from_format
(
self
):
def
test_from_format
(
self
):
support
.
import_module
(
'ctypes'
)
support
.
import_module
(
'ctypes'
)
...
@@ -2570,18 +2687,6 @@ class UnicodeTest(string_tests.CommonTest,
...
@@ -2570,18 +2687,6 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
size
,
nchar
)
self
.
assertEqual
(
size
,
nchar
)
self
.
assertEqual
(
wchar
,
nonbmp
+
'
\0
'
)
self
.
assertEqual
(
wchar
,
nonbmp
+
'
\0
'
)
def
test_subclass_add
(
self
):
class
S
(
str
):
def
__add__
(
self
,
o
):
return
"3"
self
.
assertEqual
(
S
(
"4"
)
+
S
(
"5"
),
"3"
)
class
S
(
str
):
def
__iadd__
(
self
,
o
):
return
"3"
s
=
S
(
"1"
)
s
+=
"4"
self
.
assertEqual
(
s
,
"3"
)
@support.cpython_only
@support.cpython_only
def
test_encode_decimal
(
self
):
def
test_encode_decimal
(
self
):
from
_testcapi
import
unicode_encodedecimal
from
_testcapi
import
unicode_encodedecimal
...
@@ -2610,104 +2715,6 @@ class UnicodeTest(string_tests.CommonTest,
...
@@ -2610,104 +2715,6 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
transform_decimal
(
'123
\u20ac
'
),
self
.
assertEqual
(
transform_decimal
(
'123
\u20ac
'
),
'123
\u20ac
'
)
'123
\u20ac
'
)
def
test_getnewargs
(
self
):
text
=
'abc'
args
=
text
.
__getnewargs__
()
self
.
assertIsNot
(
args
[
0
],
text
)
self
.
assertEqual
(
args
[
0
],
text
)
self
.
assertEqual
(
len
(
args
),
1
)
def
test_resize
(
self
):
for
length
in
range
(
1
,
100
,
7
):
# generate a fresh string (refcount=1)
text
=
'a'
*
length
+
'b'
with
support
.
check_warnings
((
'unicode_internal codec has been '
'deprecated'
,
DeprecationWarning
)):
# fill wstr internal field
abc
=
text
.
encode
(
'unicode_internal'
)
self
.
assertEqual
(
abc
.
decode
(
'unicode_internal'
),
text
)
# resize text: wstr field must be cleared and then recomputed
text
+=
'c'
abcdef
=
text
.
encode
(
'unicode_internal'
)
self
.
assertNotEqual
(
abc
,
abcdef
)
self
.
assertEqual
(
abcdef
.
decode
(
'unicode_internal'
),
text
)
def
test_compare
(
self
):
# Issue #17615
N
=
10
ascii
=
'a'
*
N
ascii2
=
'z'
*
N
latin
=
'
\x80
'
*
N
latin2
=
'
\xff
'
*
N
bmp
=
'
\u0100
'
*
N
bmp2
=
'
\uffff
'
*
N
astral
=
'
\U00100000
'
*
N
astral2
=
'
\U0010ffff
'
*
N
strings
=
(
ascii
,
ascii2
,
latin
,
latin2
,
bmp
,
bmp2
,
astral
,
astral2
)
for
text1
,
text2
in
itertools
.
combinations
(
strings
,
2
):
equal
=
(
text1
is
text2
)
self
.
assertEqual
(
text1
==
text2
,
equal
)
self
.
assertEqual
(
text1
!=
text2
,
not
equal
)
if
equal
:
self
.
assertTrue
(
text1
<=
text2
)
self
.
assertTrue
(
text1
>=
text2
)
# text1 is text2: duplicate strings to skip the "str1 == str2"
# optimization in unicode_compare_eq() and really compare
# character per character
copy1
=
duplicate_string
(
text1
)
copy2
=
duplicate_string
(
text2
)
self
.
assertIsNot
(
copy1
,
copy2
)
self
.
assertTrue
(
copy1
==
copy2
)
self
.
assertFalse
(
copy1
!=
copy2
)
self
.
assertTrue
(
copy1
<=
copy2
)
self
.
assertTrue
(
copy2
>=
copy2
)
self
.
assertTrue
(
ascii
<
ascii2
)
self
.
assertTrue
(
ascii
<
latin
)
self
.
assertTrue
(
ascii
<
bmp
)
self
.
assertTrue
(
ascii
<
astral
)
self
.
assertFalse
(
ascii
>=
ascii2
)
self
.
assertFalse
(
ascii
>=
latin
)
self
.
assertFalse
(
ascii
>=
bmp
)
self
.
assertFalse
(
ascii
>=
astral
)
self
.
assertFalse
(
latin
<
ascii
)
self
.
assertTrue
(
latin
<
latin2
)
self
.
assertTrue
(
latin
<
bmp
)
self
.
assertTrue
(
latin
<
astral
)
self
.
assertTrue
(
latin
>=
ascii
)
self
.
assertFalse
(
latin
>=
latin2
)
self
.
assertFalse
(
latin
>=
bmp
)
self
.
assertFalse
(
latin
>=
astral
)
self
.
assertFalse
(
bmp
<
ascii
)
self
.
assertFalse
(
bmp
<
latin
)
self
.
assertTrue
(
bmp
<
bmp2
)
self
.
assertTrue
(
bmp
<
astral
)
self
.
assertTrue
(
bmp
>=
ascii
)
self
.
assertTrue
(
bmp
>=
latin
)
self
.
assertFalse
(
bmp
>=
bmp2
)
self
.
assertFalse
(
bmp
>=
astral
)
self
.
assertFalse
(
astral
<
ascii
)
self
.
assertFalse
(
astral
<
latin
)
self
.
assertFalse
(
astral
<
bmp2
)
self
.
assertTrue
(
astral
<
astral2
)
self
.
assertTrue
(
astral
>=
ascii
)
self
.
assertTrue
(
astral
>=
latin
)
self
.
assertTrue
(
astral
>=
bmp2
)
self
.
assertFalse
(
astral
>=
astral2
)
@support.cpython_only
@support.cpython_only
def
test_pep393_utf8_caching_bug
(
self
):
def
test_pep393_utf8_caching_bug
(
self
):
# Issue #25709: Problem with string concatenation and utf-8 cache
# Issue #25709: Problem with string concatenation and utf-8 cache
...
@@ -2725,10 +2732,6 @@ class UnicodeTest(string_tests.CommonTest,
...
@@ -2725,10 +2732,6 @@ class UnicodeTest(string_tests.CommonTest,
# Check that the second call returns the same result
# Check that the second call returns the same result
self
.
assertEqual
(
getargs_s_hash
(
s
),
chr
(
k
)
.
encode
()
*
(
i
+
1
))
self
.
assertEqual
(
getargs_s_hash
(
s
),
chr
(
k
)
.
encode
()
*
(
i
+
1
))
def
test_free_after_iterating
(
self
):
support
.
check_free_after_iterating
(
self
,
iter
,
str
)
support
.
check_free_after_iterating
(
self
,
reversed
,
str
)
class
StringModuleTest
(
unittest
.
TestCase
):
class
StringModuleTest
(
unittest
.
TestCase
):
def
test_formatter_parser
(
self
):
def
test_formatter_parser
(
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