]> granicus.if.org Git - python/commitdiff
Issue #16793. Replace deprecated unittest asserts with modern counterparts.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 27 Dec 2012 22:36:34 +0000 (00:36 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 27 Dec 2012 22:36:34 +0000 (00:36 +0200)
1  2 
Lib/test/test_int.py

index 7261474a0fcf94792ee99ced86045cac2de29190,52705de438a2890e8e331285f70e5be9d46ec0ad..db79926f8fa9c3821857371aa5a76be7ac6a16bb
@@@ -238,36 -238,12 +238,36 @@@ class IntTestCases(unittest.TestCase)
      # expects x to be a string if base is given.
      @support.cpython_only
      def test_base_arg_with_no_x_arg(self):
-         self.assertEquals(int(base=6), 0)
+         self.assertEqual(int(base=6), 0)
          # Even invalid bases don't raise an exception.
-         self.assertEquals(int(base=1), 0)
-         self.assertEquals(int(base=1000), 0)
-         self.assertEquals(int(base='foo'), 0)
+         self.assertEqual(int(base=1), 0)
+         self.assertEqual(int(base=1000), 0)
+         self.assertEqual(int(base='foo'), 0)
  
 +    def test_int_base_limits(self):
 +        """Testing the supported limits of the int() base parameter."""
 +        self.assertEqual(int('0', 5), 0)
 +        with self.assertRaises(ValueError):
 +            int('0', 1)
 +        with self.assertRaises(ValueError):
 +            int('0', 37)
 +        with self.assertRaises(ValueError):
 +            int('0', -909)  # An old magic value base from Python 2.
 +        with self.assertRaises(ValueError):
 +            int('0', base=0-(2**234))
 +        with self.assertRaises(ValueError):
 +            int('0', base=2**234)
 +        # Bases 2 through 36 are supported.
 +        for base in range(2,37):
 +            self.assertEqual(int('0', base=base), 0)
 +
 +    def test_int_base_bad_types(self):
 +        """Not integer types are not valid bases; issue16772."""
 +        with self.assertRaises(TypeError):
 +            int('0', 5.5)
 +        with self.assertRaises(TypeError):
 +            int('0', 5.0)
 +
      def test_non_numeric_input_types(self):
          # Test possible non-numeric types for the argument x, including
          # subclasses of the explicitly documented accepted types.