The methods always return Decimal classes, even if they're

executed through a subclass (thanks Mark Dickinson).
Added a bit of testing for this.
This commit is contained in:
Facundo Batista 2007-09-17 17:30:13 +00:00
parent b67da23718
commit 6c398da0e7
2 changed files with 53 additions and 34 deletions

View file

@ -1072,6 +1072,21 @@ class DecimalUsabilityTest(unittest.TestCase):
checkSameDec("to_eng_string")
checkSameDec("to_integral")
def test_subclassing(self):
# Different behaviours when subclassing Decimal
class MyDecimal(Decimal):
pass
d1 = MyDecimal(1)
d2 = MyDecimal(2)
d = d1 + d2
self.assertTrue(type(d) is Decimal)
d = d1.max(d2)
self.assertTrue(type(d) is Decimal)
class DecimalPythonAPItests(unittest.TestCase):
def test_pickle(self):