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
5898fa2d
Commit
5898fa2d
authored
Nov 22, 2005
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve test coverage in Python/pystrtod.c and Python/mystrtoul.c.
parent
3b148ca4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+29
-0
No files found.
Lib/test/test_builtin.py
View file @
5898fa2d
...
...
@@ -545,6 +545,34 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
float
(
unicode
(
" 3.14 "
)),
3.14
)
self
.
assertEqual
(
float
(
unicode
(
"
\
u0663
.
\
u0661
\
u0664
"
,
'raw-unicode-escape'
)),
3.14
)
def
test_float_with_comma
(
self
):
# set locale to something that doesn't use '.' for the decimal point
try
:
import
locale
orig_locale
=
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
''
)
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
'fr_FR'
)
except
:
# if we can't set the locale, just ignore this test
return
try
:
self
.
assertEqual
(
locale
.
localeconv
()[
'decimal_point'
],
','
)
except
:
# this test is worthless, just skip it and reset the locale
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
orig_locale
)
return
try
:
self
.
assertEqual
(
float
(
" 3,14 "
),
3.14
)
self
.
assertEqual
(
float
(
" +3,14 "
),
3.14
)
self
.
assertEqual
(
float
(
" -3,14 "
),
-
3.14
)
self
.
assertEqual
(
float
(
" 0x3.1 "
),
3.0625
)
self
.
assertEqual
(
float
(
" -0x3.p-1 "
),
-
1.5
)
self
.
assertEqual
(
float
(
" 25.e-1 "
),
2.5
)
self
.
assertEqual
(
fcmp
(
float
(
" .25e-1 "
),
.
025
),
0
)
finally
:
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
orig_locale
)
def
test_floatconversion
(
self
):
# Make sure that calls to __float__() work properly
class
Foo0
:
...
...
@@ -682,6 +710,7 @@ class BuiltinTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
int
,
1
,
12
)
self
.
assertEqual
(
int
(
'0123'
,
0
),
83
)
self
.
assertEqual
(
int
(
'0x123'
,
16
),
291
)
def
test_intconversion
(
self
):
# Test __int__()
...
...
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