diff options
author | Facundo Batista <facundobatista@gmail.com> | 2007-09-17 17:30:13 +0000 |
---|---|---|
committer | Facundo Batista <facundobatista@gmail.com> | 2007-09-17 17:30:13 +0000 |
commit | 6c398da0e79cbd68ec4625f00f37a8f2a0a26e5c (patch) | |
tree | ae5d1ee9cdc5fdc3bba40646e971939ff1b92168 /Lib/test/test_decimal.py | |
parent | b67da237186f874610afd2697aaca4365d3eabec (diff) | |
download | cpython-git-6c398da0e79cbd68ec4625f00f37a8f2a0a26e5c.tar.gz |
The methods always return Decimal classes, even if they're
executed through a subclass (thanks Mark Dickinson).
Added a bit of testing for this.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index bc299ec5ec..2777b225c5 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -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): |