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
9e6ac83a
Commit
9e6ac83a
authored
Mar 09, 2017
by
Serhiy Storchaka
Committed by
GitHub
Mar 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-29773: Add more cases for testing string to float conversion errors. (#580)
parent
0f6d7334
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
Lib/test/test_float.py
Lib/test/test_float.py
+20
-8
No files found.
Lib/test/test_float.py
View file @
9e6ac83a
...
...
@@ -119,15 +119,27 @@ class GeneralFloatCases(unittest.TestCase):
self
.
assertEqual
(
float
(
memoryview
(
b'12.34'
)[
1
:
4
]),
2.3
)
def
test_error_message
(
self
):
testlist
=
(
'
\
xbd
'
,
'123
\
xbd
'
,
' 123 456 '
)
for
s
in
testlist
:
try
:
def
check
(
s
):
with
self
.
assertRaises
(
ValueError
,
msg
=
'float(%r)'
%
(
s
,))
as
cm
:
float
(
s
)
except
ValueError
as
e
:
self
.
assertIn
(
s
.
strip
(),
e
.
args
[
0
])
else
:
self
.
fail
(
"Expected int(%r) to raise a ValueError"
,
s
)
self
.
assertEqual
(
str
(
cm
.
exception
),
'could not convert string to float: %r'
%
(
s
,))
check
(
'
\
xbd
'
)
check
(
'123
\
xbd
'
)
check
(
' 123 456 '
)
check
(
b' 123 456 '
)
# non-ascii digits (error came from non-digit '!')
check
(
'
\
u0663
\
u0661
\
u0664
!'
)
# embedded NUL
check
(
'123
\
x00
'
)
check
(
'123
\
x00
245'
)
check
(
'123
\
x00
245'
)
# byte string with embedded NUL
check
(
b'123
\
x00
'
)
# non-UTF-8 byte string
check
(
b'123
\
xa0
'
)
@
support
.
run_with_locale
(
'LC_NUMERIC'
,
'fr_FR'
,
'de_DE'
)
def
test_float_with_comma
(
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