summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_int.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2012-12-28 07:31:59 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2012-12-28 07:31:59 (GMT)
commitcf095f8e0f0ed1111995a5b8a8a5ebdb189683f2 (patch)
tree03937818d78df6c7bd5f3cc8fdcbabcf0c302f2b /Lib/test/test_int.py
parent3684c79e00ad923fa2400458c1a02d6afa3c5ce8 (diff)
downloadcpython-cf095f8e0f0ed1111995a5b8a8a5ebdb189683f2.zip
cpython-cf095f8e0f0ed1111995a5b8a8a5ebdb189683f2.tar.gz
cpython-cf095f8e0f0ed1111995a5b8a8a5ebdb189683f2.tar.bz2
Issue #16761: Raise TypeError when int() or long() called with base argument only.
Diffstat (limited to 'Lib/test/test_int.py')
-rw-r--r--Lib/test/test_int.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index b3b12e6..365f9a2 100644
--- a/Lib/test/test_int.py
+++ b/Lib/test/test_int.py
@@ -60,6 +60,8 @@ class IntLongCommonTests(object):
self.assertEqual(self.ntype(x=1.2), 1)
self.assertEqual(self.ntype('100', base=2), 4)
self.assertEqual(self.ntype(x='100', base=2), 4)
+ self.assertRaises(TypeError, self.ntype, base=10)
+ self.assertRaises(TypeError, self.ntype, base=0)
class IntTestCases(IntLongCommonTests, unittest.TestCase):
@@ -365,18 +367,6 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
def test_error_on_string_base(self):
self.assertRaises(TypeError, int, 100, base='foo')
- # Include the following because in contrast CPython raises no error
- # for bad integer bases when x is not given.
- self.assertRaises(TypeError, int, base='foo')
-
- # For example, PyPy 1.9.0 raised TypeError for these cases because it
- # expects x to be a string if base is given.
- @test_support.cpython_only
- def test_int_base_without_x_returns_0(self):
- self.assertEqual(int(base=6), 0)
- # Even invalid bases don't raise an exception.
- self.assertEqual(int(base=1), 0)
- self.assertEqual(int(base=1000), 0)
@test_support.cpython_only
def test_small_ints(self):