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
784a47f2
Commit
784a47f2
authored
May 26, 2010
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #8825: additional testcases for int(string, 0) and long(string, 0).
parent
708c0727
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
Lib/test/test_int.py
Lib/test/test_int.py
+6
-0
Lib/test/test_long.py
Lib/test/test_long.py
+17
-0
No files found.
Lib/test/test_int.py
View file @
784a47f2
...
@@ -175,6 +175,12 @@ class IntTestCases(unittest.TestCase):
...
@@ -175,6 +175,12 @@ class IntTestCases(unittest.TestCase):
self
.
assertEqual
(
int
(
' 0O123 '
,
0
),
83
)
self
.
assertEqual
(
int
(
' 0O123 '
,
0
),
83
)
self
.
assertEqual
(
int
(
' 0X123 '
,
0
),
291
)
self
.
assertEqual
(
int
(
' 0X123 '
,
0
),
291
)
self
.
assertEqual
(
int
(
' 0B100 '
,
0
),
4
)
self
.
assertEqual
(
int
(
' 0B100 '
,
0
),
4
)
self
.
assertEqual
(
int
(
'0'
,
0
),
0
)
self
.
assertEqual
(
int
(
'+0'
,
0
),
0
)
self
.
assertEqual
(
int
(
'-0'
,
0
),
0
)
self
.
assertEqual
(
int
(
'00'
,
0
),
0
)
self
.
assertRaises
(
ValueError
,
int
,
'08'
,
0
)
self
.
assertRaises
(
ValueError
,
int
,
'-012395'
,
0
)
# without base still base 10
# without base still base 10
self
.
assertEqual
(
int
(
'0123'
),
123
)
self
.
assertEqual
(
int
(
'0123'
),
123
)
...
...
Lib/test/test_long.py
View file @
784a47f2
...
@@ -356,6 +356,23 @@ class LongTest(unittest.TestCase):
...
@@ -356,6 +356,23 @@ class LongTest(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
long
,
'53'
,
40
)
self
.
assertRaises
(
ValueError
,
long
,
'53'
,
40
)
self
.
assertRaises
(
TypeError
,
long
,
1
,
12
)
self
.
assertRaises
(
TypeError
,
long
,
1
,
12
)
# tests with base 0
self
.
assertEqual
(
long
(
' 0123 '
,
0
),
83
)
self
.
assertEqual
(
long
(
' 0123 '
,
0
),
83
)
self
.
assertEqual
(
long
(
'000'
,
0
),
0
)
self
.
assertEqual
(
long
(
'0o123'
,
0
),
83
)
self
.
assertEqual
(
long
(
'0x123'
,
0
),
291
)
self
.
assertEqual
(
long
(
'0b100'
,
0
),
4
)
self
.
assertEqual
(
long
(
' 0O123 '
,
0
),
83
)
self
.
assertEqual
(
long
(
' 0X123 '
,
0
),
291
)
self
.
assertEqual
(
long
(
' 0B100 '
,
0
),
4
)
self
.
assertEqual
(
long
(
'0'
,
0
),
0
)
self
.
assertEqual
(
long
(
'+0'
,
0
),
0
)
self
.
assertEqual
(
long
(
'-0'
,
0
),
0
)
self
.
assertEqual
(
long
(
'00'
,
0
),
0
)
self
.
assertRaises
(
ValueError
,
long
,
'08'
,
0
)
self
.
assertRaises
(
ValueError
,
long
,
'-012395'
,
0
)
# SF patch #1638879: embedded NULs were not detected with
# SF patch #1638879: embedded NULs were not detected with
# explicit base
# explicit base
self
.
assertRaises
(
ValueError
,
long
,
'123
\
0
'
,
10
)
self
.
assertRaises
(
ValueError
,
long
,
'123
\
0
'
,
10
)
...
...
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