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
05d54730
Commit
05d54730
authored
Mar 16, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use non-zero and non-last positions in error handler tests.
parent
98d156b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
Lib/test/test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+28
-24
No files found.
Lib/test/test_codeccallbacks.py
View file @
05d54730
...
@@ -446,18 +446,18 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -446,18 +446,18 @@ class CodecCallbackTest(unittest.TestCase):
# If the correct exception is passed in, "ignore" returns an empty replacement
# If the correct exception is passed in, "ignore" returns an empty replacement
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
ignore_errors
(
codecs
.
ignore_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\
u3042
"
,
0
,
1
,
"ouch"
)),
UnicodeEncodeError
(
"ascii"
,
"
a
\
u3042
b"
,
1
,
2
,
"ouch"
)),
(
""
,
1
)
(
""
,
2
)
)
)
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
ignore_errors
(
codecs
.
ignore_errors
(
UnicodeDecodeError
(
"ascii"
,
bytearray
(
b"
\
xff
"
),
0
,
1
,
"ouch"
)),
UnicodeDecodeError
(
"ascii"
,
bytearray
(
b"
a
\
xff
b"
),
1
,
2
,
"ouch"
)),
(
""
,
1
)
(
""
,
2
)
)
)
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
ignore_errors
(
codecs
.
ignore_errors
(
UnicodeTranslateError
(
"
\
u3042
"
,
0
,
1
,
"ouch"
)),
UnicodeTranslateError
(
"
a
\
u3042
b"
,
1
,
2
,
"ouch"
)),
(
""
,
1
)
(
""
,
2
)
)
)
def
test_badandgoodreplaceexceptions
(
self
):
def
test_badandgoodreplaceexceptions
(
self
):
...
@@ -486,18 +486,18 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -486,18 +486,18 @@ class CodecCallbackTest(unittest.TestCase):
# With the correct exception, "replace" returns an "?" or "\ufffd" replacement
# With the correct exception, "replace" returns an "?" or "\ufffd" replacement
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
replace_errors
(
codecs
.
replace_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\
u3042
"
,
0
,
1
,
"ouch"
)),
UnicodeEncodeError
(
"ascii"
,
"
a
\
u3042
b"
,
1
,
2
,
"ouch"
)),
(
"?"
,
1
)
(
"?"
,
2
)
)
)
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
replace_errors
(
codecs
.
replace_errors
(
UnicodeDecodeError
(
"ascii"
,
bytearray
(
b"
\
xff
"
),
0
,
1
,
"ouch"
)),
UnicodeDecodeError
(
"ascii"
,
bytearray
(
b"
a
\
xff
b"
),
1
,
2
,
"ouch"
)),
(
"
\
ufffd
"
,
1
)
(
"
\
ufffd
"
,
2
)
)
)
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
replace_errors
(
codecs
.
replace_errors
(
UnicodeTranslateError
(
"
\
u3042
"
,
0
,
1
,
"ouch"
)),
UnicodeTranslateError
(
"
a
\
u3042
b"
,
1
,
2
,
"ouch"
)),
(
"
\
ufffd
"
,
1
)
(
"
\
ufffd
"
,
2
)
)
)
def
test_badandgoodxmlcharrefreplaceexceptions
(
self
):
def
test_badandgoodxmlcharrefreplaceexceptions
(
self
):
...
@@ -531,9 +531,10 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -531,9 +531,10 @@ class CodecCallbackTest(unittest.TestCase):
s
=
""
.
join
(
chr
(
c
)
for
c
in
cs
)
s
=
""
.
join
(
chr
(
c
)
for
c
in
cs
)
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
xmlcharrefreplace_errors
(
codecs
.
xmlcharrefreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
s
,
0
,
len
(
s
),
"ouch"
)
UnicodeEncodeError
(
"ascii"
,
"a"
+
s
+
"b"
,
1
,
1
+
len
(
s
),
"ouch"
)
),
),
(
""
.
join
(
"&#%d;"
%
c
for
c
in
cs
),
len
(
s
))
(
""
.
join
(
"&#%d;"
%
c
for
c
in
cs
),
1
+
len
(
s
))
)
)
def
test_badandgoodbackslashreplaceexceptions
(
self
):
def
test_badandgoodbackslashreplaceexceptions
(
self
):
...
@@ -580,8 +581,9 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -580,8 +581,9 @@ class CodecCallbackTest(unittest.TestCase):
with
self
.
subTest
(
str
=
s
):
with
self
.
subTest
(
str
=
s
):
self
.
assertEqual
(
self
.
assertEqual
(
codecs
.
backslashreplace_errors
(
codecs
.
backslashreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
s
,
0
,
len
(
s
),
"ouch"
)),
UnicodeEncodeError
(
"ascii"
,
"a"
+
s
+
"b"
,
(
r
,
len
(
s
))
1
,
1
+
len
(
s
),
"ouch"
)),
(
r
,
1
+
len
(
s
))
)
)
def
test_badandgoodsurrogateescapeexceptions
(
self
):
def
test_badandgoodsurrogateescapeexceptions
(
self
):
...
@@ -614,8 +616,8 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -614,8 +616,8 @@ class CodecCallbackTest(unittest.TestCase):
)
)
self
.
assertEqual
(
self
.
assertEqual
(
surrogateescape_errors
(
surrogateescape_errors
(
UnicodeEncodeError
(
"ascii"
,
"
\
udc80
"
,
0
,
1
,
"ouch"
)),
UnicodeEncodeError
(
"ascii"
,
"
a
\
udc80
b"
,
1
,
2
,
"ouch"
)),
(
b"
\
x80
"
,
1
)
(
b"
\
x80
"
,
2
)
)
)
self
.
assertRaises
(
self
.
assertRaises
(
UnicodeDecodeError
,
UnicodeDecodeError
,
...
@@ -624,8 +626,8 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -624,8 +626,8 @@ class CodecCallbackTest(unittest.TestCase):
)
)
self
.
assertEqual
(
self
.
assertEqual
(
surrogateescape_errors
(
surrogateescape_errors
(
UnicodeDecodeError
(
"ascii"
,
bytearray
(
b"
\
x80
"
),
0
,
1
,
"ouch"
)),
UnicodeDecodeError
(
"ascii"
,
bytearray
(
b"
a
\
x80
b"
),
1
,
2
,
"ouch"
)),
(
"
\
udc80
"
,
1
)
(
"
\
udc80
"
,
2
)
)
)
def
test_badandgoodsurrogatepassexceptions
(
self
):
def
test_badandgoodsurrogatepassexceptions
(
self
):
...
@@ -685,13 +687,15 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -685,13 +687,15 @@ class CodecCallbackTest(unittest.TestCase):
with
self
.
subTest
(
encoding
=
enc
,
str
=
s
,
bytes
=
b
):
with
self
.
subTest
(
encoding
=
enc
,
str
=
s
,
bytes
=
b
):
self
.
assertEqual
(
self
.
assertEqual
(
surrogatepass_errors
(
surrogatepass_errors
(
UnicodeEncodeError
(
enc
,
s
,
0
,
len
(
s
),
"ouch"
)),
UnicodeEncodeError
(
enc
,
"a"
+
s
+
"b"
,
(
b
,
len
(
s
))
1
,
1
+
len
(
s
),
"ouch"
)),
(
b
,
1
+
len
(
s
))
)
)
self
.
assertEqual
(
self
.
assertEqual
(
surrogatepass_errors
(
surrogatepass_errors
(
UnicodeDecodeError
(
enc
,
bytearray
(
b
[:
n
]),
0
,
n
,
"ouch"
)),
UnicodeDecodeError
(
enc
,
bytearray
(
b"a"
+
b
[:
n
]
+
b"b"
),
(
s
[:
1
],
n
)
1
,
n
,
"ouch"
)),
(
s
[:
1
],
1
+
n
)
)
)
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