mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
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:
parent
b67da23718
commit
6c398da0e7
2 changed files with 53 additions and 34 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue