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
040e16e3
Kaydet (Commit)
040e16e3
authored
Kas 15, 2011
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
"unicode_internal" codec has been deprecated: fix related tests
üst
8ab440e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
29 deletions
+61
-29
test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+21
-10
test_codecs.py
Lib/test/test_codecs.py
+25
-12
test_unicode.py
Lib/test/test_unicode.py
+15
-7
No files found.
Lib/test/test_codeccallbacks.py
Dosyayı görüntüle @
040e16e3
import
test.support
,
unittest
import
sys
,
codecs
,
html
.
entities
,
unicodedata
import
codecs
import
html.entities
import
sys
import
test.support
import
unicodedata
import
unittest
import
warnings
try
:
import
ctypes
...
...
@@ -621,12 +626,15 @@ class CodecCallbackTest(unittest.TestCase):
(
"utf-7"
,
b
"+x-"
),
(
"unicode-internal"
,
b
"
\x00
"
),
):
self
.
assertRaises
(
TypeError
,
bytes
.
decode
,
enc
,
"test.badhandler"
)
with
warnings
.
catch_warnings
():
# unicode-internal has been deprecated
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
self
.
assertRaises
(
TypeError
,
bytes
.
decode
,
enc
,
"test.badhandler"
)
def
test_lookup
(
self
):
self
.
assertEqual
(
codecs
.
strict_errors
,
codecs
.
lookup_error
(
"strict"
))
...
...
@@ -842,8 +850,11 @@ class CodecCallbackTest(unittest.TestCase):
else
:
raise
TypeError
(
"don't know how to handle
%
r"
%
exc
)
codecs
.
register_error
(
"test.replacing"
,
replacing
)
for
(
encoding
,
data
)
in
baddata
:
self
.
assertRaises
(
TypeError
,
data
.
decode
,
encoding
,
"test.replacing"
)
with
warnings
.
catch_warnings
():
# unicode-internal has been deprecated
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
for
(
encoding
,
data
)
in
baddata
:
self
.
assertRaises
(
TypeError
,
data
.
decode
,
encoding
,
"test.replacing"
)
def
mutating
(
exc
):
if
isinstance
(
exc
,
UnicodeDecodeError
):
...
...
Lib/test/test_codecs.py
Dosyayı görüntüle @
040e16e3
from
test
import
support
import
unittest
import
_testcapi
import
codecs
import
io
import
locale
import
sys
,
_testcapi
,
io
import
sys
import
unittest
import
warnings
from
test
import
support
if
sys
.
platform
==
'win32'
:
VISTA_OR_LATER
=
(
sys
.
getwindowsversion
()
.
major
>=
6
)
...
...
@@ -1051,12 +1055,16 @@ class UnicodeInternalTest(unittest.TestCase):
self
.
assertEqual
((
"ab"
,
12
),
ignored
)
def
test_encode_length
(
self
):
# Issue 3739
encoder
=
codecs
.
getencoder
(
"unicode_internal"
)
self
.
assertEqual
(
encoder
(
"a"
)[
1
],
1
)
self
.
assertEqual
(
encoder
(
"
\xe9\u0142
"
)[
1
],
2
)
with
warnings
.
catch_warnings
():
# unicode-internal has been deprecated
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
# Issue 3739
encoder
=
codecs
.
getencoder
(
"unicode_internal"
)
self
.
assertEqual
(
encoder
(
"a"
)[
1
],
1
)
self
.
assertEqual
(
encoder
(
"
\xe9\u0142
"
)[
1
],
2
)
self
.
assertEqual
(
codecs
.
escape_encode
(
br
'
\x00
'
)[
1
],
4
)
self
.
assertEqual
(
codecs
.
escape_encode
(
br
'
\x00
'
)[
1
],
4
)
# From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
nameprep_tests
=
[
...
...
@@ -1512,10 +1520,15 @@ class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling):
elif
encoding
==
"latin_1"
:
name
=
"latin_1"
self
.
assertEqual
(
encoding
.
replace
(
"_"
,
"-"
),
name
.
replace
(
"_"
,
"-"
))
(
b
,
size
)
=
codecs
.
getencoder
(
encoding
)(
s
)
self
.
assertEqual
(
size
,
len
(
s
),
"
%
r !=
%
r (encoding=
%
r)"
%
(
size
,
len
(
s
),
encoding
))
(
chars
,
size
)
=
codecs
.
getdecoder
(
encoding
)(
b
)
self
.
assertEqual
(
chars
,
s
,
"
%
r !=
%
r (encoding=
%
r)"
%
(
chars
,
s
,
encoding
))
with
warnings
.
catch_warnings
():
# unicode-internal has been deprecated
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
(
b
,
size
)
=
codecs
.
getencoder
(
encoding
)(
s
)
self
.
assertEqual
(
size
,
len
(
s
),
"
%
r !=
%
r (encoding=
%
r)"
%
(
size
,
len
(
s
),
encoding
))
(
chars
,
size
)
=
codecs
.
getdecoder
(
encoding
)(
b
)
self
.
assertEqual
(
chars
,
s
,
"
%
r !=
%
r (encoding=
%
r)"
%
(
chars
,
s
,
encoding
))
if
encoding
not
in
broken_unicode_with_streams
:
# check stream reader/writer
...
...
Lib/test/test_unicode.py
Dosyayı görüntüle @
040e16e3
...
...
@@ -5,13 +5,13 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""
#"
import
_string
import
codecs
import
struct
import
sys
import
unittest
import
warnings
from
test
import
support
,
string_tests
import
_string
# Error handling (bad decoder return)
def
search_function
(
encoding
):
...
...
@@ -1394,7 +1394,11 @@ class UnicodeTest(string_tests.CommonTest,
for
encoding
in
(
'utf-7'
,
'utf-8'
,
'utf-16'
,
'utf-16-le'
,
'utf-16-be'
,
'raw_unicode_escape'
,
'unicode_escape'
,
'unicode_internal'
):
self
.
assertEqual
(
str
(
u
.
encode
(
encoding
),
encoding
),
u
)
with
warnings
.
catch_warnings
():
# unicode-internal has been deprecated
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
self
.
assertEqual
(
str
(
u
.
encode
(
encoding
),
encoding
),
u
)
# Roundtrip safety for BMP (just the first 256 chars)
for
c
in
range
(
256
):
...
...
@@ -1409,11 +1413,15 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
str
(
u
.
encode
(
encoding
),
encoding
),
u
)
# Roundtrip safety for non-BMP (just a few chars)
u
=
'
\U00010001\U00020002\U00030003\U00040004\U00050005
'
for
encoding
in
(
'utf-8'
,
'utf-16'
,
'utf-16-le'
,
'utf-16-be'
,
'raw_unicode_escape'
,
'unicode_escape'
,
'unicode_internal'
):
self
.
assertEqual
(
str
(
u
.
encode
(
encoding
),
encoding
),
u
)
with
warnings
.
catch_warnings
():
# unicode-internal has been deprecated
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
u
=
'
\U00010001\U00020002\U00030003\U00040004\U00050005
'
for
encoding
in
(
'utf-8'
,
'utf-16'
,
'utf-16-le'
,
'utf-16-be'
,
'raw_unicode_escape'
,
'unicode_escape'
,
'unicode_internal'
):
self
.
assertEqual
(
str
(
u
.
encode
(
encoding
),
encoding
),
u
)
# UTF-8 must be roundtrip safe for all code points
# (except surrogates, which are forbidden).
...
...
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