summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-12-11 19:28:47 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-12-11 19:28:47 (GMT)
commit017052152befb71433a434600e36a6389109546d (patch)
treea773b96bd65742e648aed50f8576bf6660664bc0
parent145b479508c7730a50e905c219e05c2b6d2450b7 (diff)
downloadcpython-017052152befb71433a434600e36a6389109546d.zip
cpython-017052152befb71433a434600e36a6389109546d.tar.gz
cpython-017052152befb71433a434600e36a6389109546d.tar.bz2
Fiddle test_class so it passes with -Qnew.
-rw-r--r--Lib/test/test_class.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index c1c663c..151074e 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -88,10 +88,17 @@ class AllTests:
def __del__(self, *args):
print "__del__:", args
+# Synthesize AllTests methods from the names in testmeths.
+
+method_template = """\
+def __%(method)s__(self, *args):
+ print "__%(method)s__:", args
+"""
+
for method in testmeths:
- exec """def __%(method)s__(self, *args):
- print "__%(method)s__:", args
-"""%locals() in AllTests.__dict__
+ exec method_template % locals() in AllTests.__dict__
+
+del method, method_template
# this also tests __init__ of course.
testme = AllTests()
@@ -107,8 +114,16 @@ testme - 1
testme * 1
1 * testme
-testme / 1
-1 / testme
+if 1/2 == 0:
+ testme / 1
+ 1 / testme
+else:
+ # True division is in effect, so "/" doesn't map to __div__ etc; but
+ # the canned expected-output file requires that __div__ etc get called.
+ testme.__coerce__(1)
+ testme.__div__(1)
+ testme.__coerce__(1)
+ testme.__rdiv__(1)
testme % 1
1 % testme