diff options
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r-- | Lib/test/test_float.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 5278d71..b656582 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -223,6 +223,21 @@ class GeneralFloatCases(unittest.TestCase): with self.assertWarns(DeprecationWarning): self.assertIs(type(FloatSubclass(F())), FloatSubclass) + class MyIndex: + def __init__(self, value): + self.value = value + def __index__(self): + return self.value + + self.assertEqual(float(MyIndex(42)), 42.0) + self.assertRaises(OverflowError, float, MyIndex(2**2000)) + + class MyInt: + def __int__(self): + return 42 + + self.assertRaises(TypeError, float, MyInt()) + def test_keyword_args(self): with self.assertRaisesRegex(TypeError, 'keyword argument'): float(x='3.14') |