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
00b2c86d
Kaydet (Commit)
00b2c86d
authored
Eki 05, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix text failures when ctypes is not available
(followup to Victor's 85d11cf67aa8 and 7a50e549bd11)
üst
4637309e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
28 deletions
+39
-28
test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+32
-26
test_codecs.py
Lib/test/test_codecs.py
+7
-2
No files found.
Lib/test/test_codeccallbacks.py
Dosyayı görüntüle @
00b2c86d
import
test.support
,
unittest
import
sys
,
codecs
,
html
.
entities
,
unicodedata
import
ctypes
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
try
:
import
ctypes
except
ImportError
:
ctypes
=
None
SIZEOF_WCHAR_T
=
-
1
else
:
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
class
PosReturn
:
# this can be used for configurable callbacks
...
...
@@ -572,33 +577,34 @@ class CodecCallbackTest(unittest.TestCase):
UnicodeEncodeError
(
"ascii"
,
"
\uffff
"
,
0
,
1
,
"ouch"
)),
(
"
\\
uffff"
,
1
)
)
if
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
==
2
:
if
SIZEOF_WCHAR_T
==
2
:
len_wide
=
2
else
:
len_wide
=
1
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\U00010000
"
,
0
,
len_wide
,
"ouch"
)),
(
"
\\
U00010000"
,
len_wide
)
)
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\U0010ffff
"
,
0
,
len_wide
,
"ouch"
)),
(
"
\\
U0010ffff"
,
len_wide
)
)
# Lone surrogates (regardless of unicode width)
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\ud800
"
,
0
,
1
,
"ouch"
)),
(
"
\\
ud800"
,
1
)
)
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\udfff
"
,
0
,
1
,
"ouch"
)),
(
"
\\
udfff"
,
1
)
)
if
SIZEOF_WCHAR_T
>
0
:
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\U00010000
"
,
0
,
len_wide
,
"ouch"
)),
(
"
\\
U00010000"
,
len_wide
)
)
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\U0010ffff
"
,
0
,
len_wide
,
"ouch"
)),
(
"
\\
U0010ffff"
,
len_wide
)
)
# Lone surrogates (regardless of unicode width)
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\ud800
"
,
0
,
1
,
"ouch"
)),
(
"
\\
ud800"
,
1
)
)
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\udfff
"
,
0
,
1
,
"ouch"
)),
(
"
\\
udfff"
,
1
)
)
def
test_badhandlerresults
(
self
):
results
=
(
42
,
"foo"
,
(
1
,
2
,
3
),
(
"foo"
,
1
,
3
),
(
"foo"
,
None
),
(
"foo"
,),
(
"foo"
,
1
,
3
),
(
"foo"
,
None
),
(
"foo"
,)
)
...
...
Lib/test/test_codecs.py
Dosyayı görüntüle @
00b2c86d
...
...
@@ -3,9 +3,14 @@ import unittest
import
codecs
import
locale
import
sys
,
_testcapi
,
io
import
ctypes
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
try
:
import
ctypes
except
ImportError
:
ctypes
=
None
SIZEOF_WCHAR_T
=
-
1
else
:
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
class
Queue
(
object
):
"""
...
...
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