Skip to content
Prev Previous commit
Apply suggestions from code review
  • Loading branch information
serhiy-storchaka authored Nov 5, 2023
commit 463ec446a43fabfa359049a8d6ea5d0edad984de
9 changes: 2 additions & 7 deletions Lib/test/test_capi/test_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@


class CAPIFloatTest(unittest.TestCase):
def assertEqualWithSign(self, actual, expected):
self.assertEqual(actual, expected)
self.assertEqual(math.copysign(1, actual), math.copysign(1, expected))

def test_check(self):
# Test PyFloat_Check()
check = _testcapi.float_check
Expand All @@ -26,7 +22,6 @@ def test_check(self):
self.assertTrue(check(FloatSubclass(4.25)))
self.assertFalse(check(Float()))
self.assertFalse(check(3))
self.assertFalse(check([]))
self.assertFalse(check(object()))

# CRASHES check(NULL)
Expand All @@ -39,7 +34,6 @@ def test_checkexact(self):
self.assertFalse(checkexact(FloatSubclass(4.25)))
self.assertFalse(checkexact(Float()))
self.assertFalse(checkexact(3))
self.assertFalse(checkexact([]))
self.assertFalse(checkexact(object()))

# CRASHES checkexact(NULL)
Expand Down Expand Up @@ -78,8 +72,9 @@ def __float__(self):
raise RuntimeError

self.assertEqual(asdouble(4.25), 4.25)
self.assertEqual(asdouble(-1), -1.0)
self.assertEqual(asdouble(-1.0), -1.0)
self.assertEqual(asdouble(42), 42.0)
self.assertEqual(asdouble(-1), -1.0)
Comment thread
skirpichev marked this conversation as resolved.
self.assertEqual(asdouble(2**1000), float(2**1000))

self.assertEqual(asdouble(FloatSubclass(4.25)), 4.25)
Expand Down
2 changes: 1 addition & 1 deletion Modules/_testcapi/float.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ float_asdouble(PyObject *Py_UNUSED(module), PyObject *obj)
return PyFloat_FromDouble(d);
}

static PyObject*
static PyObject *
float_getinfo(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(arg))
{
return PyFloat_GetInfo();
Expand Down