summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-05-26 19:14:01 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-05-26 19:14:01 (GMT)
commit56544db46d4efceed4970a8bdf69f0e425738ed6 (patch)
tree28fb5bcc3a7cd3b6f020e18f8d883b9c310642a8 /Lib
parent6da11e5fce42f7e79c93b5e523d1be03bdc7182e (diff)
downloadcpython-56544db46d4efceed4970a8bdf69f0e425738ed6.zip
cpython-56544db46d4efceed4970a8bdf69f0e425738ed6.tar.gz
cpython-56544db46d4efceed4970a8bdf69f0e425738ed6.tar.bz2
Merged revisions 81551 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81551 | mark.dickinson | 2010-05-26 20:06:33 +0100 (Wed, 26 May 2010) | 1 line Issue #8825: additional testcases for int(string, 0) and long(string, 0). ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_long.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index eea67e6..c47b8e3 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -330,6 +330,21 @@ class LongTest(unittest.TestCase):
# ... but it's just a normal digit if base >= 22
self.assertEqual(int('1L', 22), 43)
+ # tests with base 0
+ self.assertEqual(int('000', 0), 0)
+ self.assertEqual(int('0o123', 0), 83)
+ self.assertEqual(int('0x123', 0), 291)
+ self.assertEqual(int('0b100', 0), 4)
+ self.assertEqual(int(' 0O123 ', 0), 83)
+ self.assertEqual(int(' 0X123 ', 0), 291)
+ 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)
+
def test_conversion(self):
class JustLong: