Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e8cfe521
Commit
e8cfe521
authored
Mar 15, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increased coverage of standard codec error handlers.
parent
74108dda
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
30 deletions
+42
-30
Lib/test/test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+42
-30
No files found.
Lib/test/test_codeccallbacks.py
View file @
e8cfe521
...
@@ -441,6 +441,16 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -441,6 +441,16 @@ class CodecCallbackTest(unittest.TestCase):
codecs
.
strict_errors
,
codecs
.
strict_errors
,
UnicodeEncodeError
(
"ascii"
,
u"
\
u3042
"
,
0
,
1
,
"ouch"
)
UnicodeEncodeError
(
"ascii"
,
u"
\
u3042
"
,
0
,
1
,
"ouch"
)
)
)
self
.
assertRaises
(
UnicodeDecodeError
,
codecs
.
strict_errors
,
UnicodeDecodeError
(
"ascii"
,
"
\
xff
"
,
0
,
1
,
"ouch"
)
)
self
.
assertRaises
(
UnicodeTranslateError
,
codecs
.
strict_errors
,
UnicodeTranslateError
(
u"
\
u3042
"
,
0
,
1
,
"ouch"
)
)
def
test_badandgoodignoreexceptions
(
self
):
def
test_badandgoodignoreexceptions
(
self
):
# "ignore" complains about a non-exception passed in
# "ignore" complains about a non-exception passed in
...
@@ -531,13 +541,16 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -531,13 +541,16 @@ class CodecCallbackTest(unittest.TestCase):
UnicodeTranslateError
(
u"
\
u3042
"
,
0
,
1
,
"ouch"
)
UnicodeTranslateError
(
u"
\
u3042
"
,
0
,
1
,
"ouch"
)
)
)
# Use the correct exception
# Use the correct exception
cs
=
(
0
,
1
,
9
,
10
,
99
,
100
,
999
,
1000
,
9999
,
10000
,
0x3042
)
cs
=
(
0
,
1
,
9
,
10
,
99
,
100
,
999
,
1000
,
9999
,
10000
)
s
=
""
.
join
(
unichr
(
c
)
for
c
in
cs
)
cs
+=
(
0xdfff
,
0xd800
)
s
=
u""
.
join
(
unichr
(
c
)
for
c
in
cs
)
s
+=
u"
\
U0001869f
\
U000186a0
\
U000f423f
\
U000f4240
"
cs
+=
(
99999
,
100000
,
999999
,
1000000
)
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
xmlcharrefreplace_errors
(
codecs
.
xmlcharrefreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
s
,
0
,
len
(
s
),
"ouch"
)
UnicodeEncodeError
(
"ascii"
,
s
,
0
,
len
(
s
),
"ouch"
)
),
),
(
u""
.
join
(
u"&#%d;"
%
ord
(
c
)
for
c
in
s
),
len
(
s
))
(
u""
.
join
(
u"&#%d;"
%
c
for
c
in
c
s
),
len
(
s
))
)
)
def
test_badandgoodbackslashreplaceexceptions
(
self
):
def
test_badandgoodbackslashreplaceexceptions
(
self
):
...
@@ -565,34 +578,33 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -565,34 +578,33 @@ class CodecCallbackTest(unittest.TestCase):
UnicodeTranslateError
(
u"
\
u3042
"
,
0
,
1
,
"ouch"
)
UnicodeTranslateError
(
u"
\
u3042
"
,
0
,
1
,
"ouch"
)
)
)
# Use the correct exception
# Use the correct exception
self
.
assertEqual
(
tests
=
[
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
u"
\
u3042
"
,
0
,
1
,
"ouch"
)),
(
u"
\
u3042
"
,
u"
\
\
u3042"
),
(
u"
\
\
u3042"
,
1
)
(
u"
\
n
"
,
u"
\
\
x0a"
),
)
(
u"a"
,
u"
\
\
x61"
),
self
.
assertEqual
(
(
u"
\
x00
"
,
u"
\
\
x00"
),
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
u"
\
x00
"
,
0
,
1
,
"ouch"
)),
(
u"
\
xff
"
,
u"
\
\
xff"
),
(
u"
\
\
x00"
,
1
)
(
u"
\
u0100
"
,
u"
\
\
u0100"
),
)
(
u"
\
uffff
"
,
u"
\
\
uffff"
),
self
.
assertEqual
(
# Lone surrogates
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
u"
\
xff
"
,
0
,
1
,
"ouch"
)),
(
u"
\
ud800
"
,
u"
\
\
ud800"
),
(
u"
\
\
xff"
,
1
)
(
u"
\
udfff
"
,
u"
\
\
udfff"
),
)
]
self
.
assertEqual
(
if
sys
.
maxunicode
>
0xffff
:
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
u"
\
u0100
"
,
0
,
1
,
"ouch"
)),
tests
+=
[
(
u"
\
\
u0100"
,
1
)
(
u"
\
U00010000
"
,
u"
\
\
U00010000"
),
)
(
u"
\
U0010ffff
"
,
u"
\
\
U0010ffff"
),
self
.
assertEqual
(
]
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
u"
\
uffff
"
,
0
,
1
,
"ouch"
)),
else
:
(
u"
\
\
uffff"
,
1
)
tests
+=
[
)
(
u"
\
U00010000
"
,
u"
\
\
ud800
\
\
udc00"
),
if
sys
.
maxunicode
>
0xffff
:
(
u"
\
U0010ffff
"
,
u"
\
\
udbff
\
\
udfff"
),
self
.
assertEqual
(
]
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
u"
\
U00010000
"
,
0
,
1
,
"ouch"
)),
for
s
,
r
in
tests
:
(
u"
\
\
U00010000"
,
1
)
)
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
u"
\
U0010ffff
"
,
0
,
1
,
"ouch"
)),
codecs
.
backslashreplace_errors
(
(
u"
\
\
U0010ffff"
,
1
)
UnicodeEncodeError
(
"ascii"
,
s
,
0
,
len
(
s
),
"ouch"
)),
(
r
,
len
(
s
))
)
)
def
test_badhandlerresults
(
self
):
def
test_badhandlerresults
(
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