diff options
author | Stefan Krah <skrah@bytereef.org> | 2016-06-20 10:10:13 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2016-06-20 10:10:13 (GMT) |
commit | 6817c59cf08ac214737d86f37e63a431385a9613 (patch) | |
tree | d3f91e41a3063cbcc86a99dfa7fbc8fec43841d3 /Lib | |
parent | 2275e626b1694557f646fd8a06608074731d6c82 (diff) | |
download | cpython-6817c59cf08ac214737d86f37e63a431385a9613.zip cpython-6817c59cf08ac214737d86f37e63a431385a9613.tar.gz cpython-6817c59cf08ac214737d86f37e63a431385a9613.tar.bz2 |
Issue #27006: from_float(): call the subclass' __new__() and __init__().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_decimal.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index c0d21b1..cde5d78 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -2491,7 +2491,8 @@ class PythonAPItests(unittest.TestCase): Decimal = self.decimal.Decimal class MyDecimal(Decimal): - pass + def __init__(self, _): + self.x = 'y' self.assertTrue(issubclass(MyDecimal, Decimal)) @@ -2499,6 +2500,8 @@ class PythonAPItests(unittest.TestCase): self.assertEqual(type(r), MyDecimal) self.assertEqual(str(r), '0.1000000000000000055511151231257827021181583404541015625') + self.assertEqual(r.x, 'y') + bigint = 12345678901234567890123456789 self.assertEqual(MyDecimal.from_float(bigint), MyDecimal(bigint)) self.assertTrue(MyDecimal.from_float(float('nan')).is_qnan()) |