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

Method test_internal_use_of_overridden_methods

Lib/test/test_decimal.py:5710–5736  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5708 self.assertEqual(y, x+4)
5709
5710 def test_internal_use_of_overridden_methods(self):
5711 Decimal = C.Decimal
5712
5713 # Unsound subtyping
5714 class X(float):
5715 def as_integer_ratio(self):
5716 return 1
5717 def __abs__(self):
5718 return self
5719
5720 class Y(float):
5721 def __abs__(self):
5722 return [1]*200
5723
5724 class I(int):
5725 def bit_length(self):
5726 return [1]*200
5727
5728 class Z(float):
5729 def as_integer_ratio(self):
5730 return (I(1), I(1))
5731 def __abs__(self):
5732 return self
5733
5734 for cls in X, Y, Z:
5735 self.assertEqual(Decimal.from_float(cls(101.1)),
5736 Decimal.from_float(101.1))
5737
5738 def test_c_immutable_types(self):
5739 SignalDict = type(C.Context().flags)

Callers

nothing calls this directly

Calls 3

clsClass · 0.50
assertEqualMethod · 0.45
from_floatMethod · 0.45

Tested by

no test coverage detected