MCPcopy Index your code
hub / github.com/python/cpython / test_float

Method test_float

Lib/test/test_statistics.py:968–976  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

966 self.check_exact_equal(x, MyFraction(71, 13))
967
968 def test_float(self):
969 # Test conversions to float.
970 x = statistics._convert(Fraction(-1, 2), float)
971 self.check_exact_equal(x, -0.5)
972 class MyFloat(float):
973 def __truediv__(self, other):
974 return self.__class__(super().__truediv__(other))
975 x = statistics._convert(Fraction(9, 8), MyFloat)
976 self.check_exact_equal(x, MyFloat(1.125))
977
978 def test_decimal(self):
979 # Test conversions to Decimal.

Callers

nothing calls this directly

Calls 3

check_exact_equalMethod · 0.95
FractionClass · 0.90
MyFloatClass · 0.70

Tested by

no test coverage detected