mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)
Only __index__ should be used to make integer conversions lossless.
This commit is contained in:
parent
8ad052464a
commit
578c3955e0
87 changed files with 226 additions and 2937 deletions
|
|
@ -502,14 +502,10 @@ class MathTests(unittest.TestCase):
|
|||
self.assertRaises(ValueError, math.factorial, -10**100)
|
||||
|
||||
def testFactorialNonIntegers(self):
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(math.factorial(5.0), 120)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertRaises(ValueError, math.factorial, 5.2)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertRaises(ValueError, math.factorial, -1.0)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertRaises(ValueError, math.factorial, -1e100)
|
||||
self.assertRaises(TypeError, math.factorial, 5.0)
|
||||
self.assertRaises(TypeError, math.factorial, 5.2)
|
||||
self.assertRaises(TypeError, math.factorial, -1.0)
|
||||
self.assertRaises(TypeError, math.factorial, -1e100)
|
||||
self.assertRaises(TypeError, math.factorial, decimal.Decimal('5'))
|
||||
self.assertRaises(TypeError, math.factorial, decimal.Decimal('5.2'))
|
||||
self.assertRaises(TypeError, math.factorial, "5")
|
||||
|
|
@ -520,8 +516,7 @@ class MathTests(unittest.TestCase):
|
|||
# Currently raises OverflowError for inputs that are too large
|
||||
# to fit into a C long.
|
||||
self.assertRaises(OverflowError, math.factorial, 10**100)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertRaises(OverflowError, math.factorial, 1e100)
|
||||
self.assertRaises(TypeError, math.factorial, 1e100)
|
||||
|
||||
def testFloor(self):
|
||||
self.assertRaises(TypeError, math.floor)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue