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
9fc5981e
Kaydet (Commit)
9fc5981e
authored
Nis 08, 2013
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17615: Add tests comparing Unicode strings of different kinds
Kinds: ascii, latin, bmp, astral.
üst
c1302bba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
test_unicode.py
Lib/test/test_unicode.py
+85
-0
No files found.
Lib/test/test_unicode.py
Dosyayı görüntüle @
9fc5981e
...
@@ -7,6 +7,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
...
@@ -7,6 +7,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
"""
#"
"""
#"
import
_string
import
_string
import
codecs
import
codecs
import
itertools
import
struct
import
struct
import
sys
import
sys
import
unittest
import
unittest
...
@@ -31,6 +32,16 @@ def search_function(encoding):
...
@@ -31,6 +32,16 @@ def search_function(encoding):
return
None
return
None
codecs
.
register
(
search_function
)
codecs
.
register
(
search_function
)
def
duplicate_string
(
text
):
"""
Try to get a fresh clone of the specified text:
new object with a reference count of 1.
This is a best-effort: latin1 single letters and the empty
string ('') are singletons and cannot be cloned.
"""
return
text
.
encode
()
.
decode
()
class
UnicodeTest
(
string_tests
.
CommonTest
,
class
UnicodeTest
(
string_tests
.
CommonTest
,
string_tests
.
MixinStrUnicodeUserStringTest
,
string_tests
.
MixinStrUnicodeUserStringTest
,
string_tests
.
MixinStrUnicodeTest
,
string_tests
.
MixinStrUnicodeTest
,
...
@@ -2208,6 +2219,80 @@ class UnicodeTest(string_tests.CommonTest,
...
@@ -2208,6 +2219,80 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertNotEqual
(
abc
,
abcdef
)
self
.
assertNotEqual
(
abc
,
abcdef
)
self
.
assertEqual
(
abcdef
.
decode
(
'unicode_internal'
),
text
)
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
)
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