summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-03-28 08:06:35 (GMT)
committerGeorg Brandl <georg@python.org>2006-03-28 08:06:35 (GMT)
commit96c3f7f56bcbb1db26d0b09cfe17b89dd032a813 (patch)
tree75af33380d37d209a25ac4765420299350f48deb /Lib/test/test_decimal.py
parentdf511798e463195e2b97bfa8cea4cc487d690e50 (diff)
downloadcpython-96c3f7f56bcbb1db26d0b09cfe17b89dd032a813.zip
cpython-96c3f7f56bcbb1db26d0b09cfe17b89dd032a813.tar.gz
cpython-96c3f7f56bcbb1db26d0b09cfe17b89dd032a813.tar.bz2
Make test_decimal work with -Qnew.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 34f034b..29b28ef 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -503,16 +503,22 @@ class DecimalImplicitConstructionTest(unittest.TestCase):
self.assertEqual(eval('Decimal(10) != E()'), 'ne 10')
# insert operator methods and then exercise them
- for sym, lop, rop in (
- ('+', '__add__', '__radd__'),
- ('-', '__sub__', '__rsub__'),
- ('*', '__mul__', '__rmul__'),
- ('/', '__div__', '__rdiv__'),
- ('%', '__mod__', '__rmod__'),
- ('//', '__floordiv__', '__rfloordiv__'),
- ('**', '__pow__', '__rpow__'),
- ):
-
+ oplist = [
+ ('+', '__add__', '__radd__'),
+ ('-', '__sub__', '__rsub__'),
+ ('*', '__mul__', '__rmul__'),
+ ('%', '__mod__', '__rmod__'),
+ ('//', '__floordiv__', '__rfloordiv__'),
+ ('**', '__pow__', '__rpow__')
+ ]
+ if 1/2 == 0:
+ # testing with classic division, so add __div__
+ oplist.append(('/', '__div__', '__rdiv__'))
+ else:
+ # testing with -Qnew, so add __truediv__
+ oplist.append(('/', '__truediv__', '__rtruediv__'))
+
+ for sym, lop, rop in oplist:
setattr(E, lop, lambda self, other: 'str' + lop + str(other))
setattr(E, rop, lambda self, other: str(other) + rop + 'str')
self.assertEqual(eval('E()' + sym + 'Decimal(10)'),