summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-11-08 10:17:29 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-11-08 10:17:29 (GMT)
commit0f82b76b574724618f7de929c0f30aecc58c3bf7 (patch)
tree216c9b54663d9684657bba8503422071278fdf0d /Lib/test/test_decimal.py
parent9cfa1ff891af6394cfcd4373c0c7d1e2a2dfd371 (diff)
downloadcpython-0f82b76b574724618f7de929c0f30aecc58c3bf7.zip
cpython-0f82b76b574724618f7de929c0f30aecc58c3bf7.tar.gz
cpython-0f82b76b574724618f7de929c0f30aecc58c3bf7.tar.bz2
Issue #16431: Finally, consider all permutations.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index ea18c63..dd4c73c 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -2029,7 +2029,7 @@ class UsabilityTest(unittest.TestCase):
Decimal = self.decimal.Decimal
class MyDecimal(Decimal):
- pass
+ y = None
d1 = MyDecimal(1)
d2 = MyDecimal(2)
@@ -2047,14 +2047,29 @@ class UsabilityTest(unittest.TestCase):
self.assertIs(type(d), MyDecimal)
self.assertEqual(d, d1)
- a = Decimal('1.0')
- b = MyDecimal(a)
- self.assertIs(type(b), MyDecimal)
- self.assertEqual(a, b)
-
- c = Decimal(b)
- self.assertIs(type(c), Decimal)
- self.assertEqual(a, c)
+ # Decimal(Decimal)
+ d = Decimal('1.0')
+ x = Decimal(d)
+ self.assertIs(type(x), Decimal)
+ self.assertEqual(x, d)
+
+ # MyDecimal(Decimal)
+ m = MyDecimal(d)
+ self.assertIs(type(m), MyDecimal)
+ self.assertEqual(m, d)
+ self.assertIs(m.y, None)
+
+ # Decimal(MyDecimal)
+ x = Decimal(m)
+ self.assertIs(type(x), Decimal)
+ self.assertEqual(x, d)
+
+ # MyDecimal(MyDecimal)
+ m.y = 9
+ x = MyDecimal(m)
+ self.assertIs(type(x), MyDecimal)
+ self.assertEqual(x, d)
+ self.assertIs(x.y, None)
def test_implicit_context(self):
Decimal = self.decimal.Decimal