(self)
| 275 | self.assertRaises(SystemError, long, NULL) |
| 276 | |
| 277 | def test_float(self): |
| 278 | # Test PyNumber_Float() |
| 279 | float_ = _testcapi.number_float |
| 280 | |
| 281 | self.assertEqual(float_(1.25), 1.25) |
| 282 | self.assertEqual(float_(123), 123.) |
| 283 | self.assertEqual(float_("1.25"), 1.25) |
| 284 | |
| 285 | self.assertEqual(float_(FloatLike.with_val(4.25)), 4.25) |
| 286 | self.assertEqual(float_(IndexLike.with_val(99)), 99.0) |
| 287 | self.assertEqual(float_(IndexLike.with_val(-1)), -1.0) |
| 288 | |
| 289 | self.assertRaises(TypeError, float_, FloatLike.with_val(687)) |
| 290 | with warnings.catch_warnings(): |
| 291 | warnings.simplefilter("error", DeprecationWarning) |
| 292 | self.assertRaises(DeprecationWarning, float_, FloatLike.with_val(subclassof(float)(4.25))) |
| 293 | with self.assertWarns(DeprecationWarning): |
| 294 | self.assertEqual(float_(FloatLike.with_val(subclassof(float)(4.25))), 4.25) |
| 295 | self.assertRaises(RuntimeError, float_, FloatLike.with_exc(RuntimeError)) |
| 296 | |
| 297 | self.assertRaises(TypeError, float_, IndexLike.with_val(1.25)) |
| 298 | self.assertRaises(OverflowError, float_, IndexLike.with_val(2**2000)) |
| 299 | |
| 300 | self.assertRaises(TypeError, float_, 1j) |
| 301 | self.assertRaises(TypeError, float_, object()) |
| 302 | self.assertRaises(SystemError, float_, NULL) |
| 303 | |
| 304 | def test_index(self): |
| 305 | # Test PyNumber_Index() |
nothing calls this directly
no test coverage detected