summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMoshe Zadka <moshez@math.huji.ac.il>2001-01-29 06:21:17 (GMT)
committerMoshe Zadka <moshez@math.huji.ac.il>2001-01-29 06:21:17 (GMT)
commit497671e094b7f18221cc1f872bfe68afc57c860b (patch)
tree82c5fb1c0b85a8670c71c9146ee9c5b34c08a43e /Lib/test
parent2beeb22533acf5fbc29e650003a79d633aecffc0 (diff)
downloadcpython-497671e094b7f18221cc1f872bfe68afc57c860b.zip
cpython-497671e094b7f18221cc1f872bfe68afc57c860b.tar.gz
cpython-497671e094b7f18221cc1f872bfe68afc57c860b.tar.bz2
The one thing I love more then writing code is deleting code.
* Removed func_hash and func_compare, so they can be treated as immutable content-less objects (address hash and comparison) * Added tests to that affect to test_funcattrs (also testing func_code is writable) * Reverse meaning of tests in test_opcodes which checked identical code gets identical functions
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_funcattrs.py19
-rw-r--r--Lib/test/test_opcodes.py14
2 files changed, 26 insertions, 7 deletions
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py
index 9c07a8f..0591ba6 100644
--- a/Lib/test/test_funcattrs.py
+++ b/Lib/test/test_funcattrs.py
@@ -154,3 +154,22 @@ else: raise TestFailed
# This isn't specifically related to function attributes, but it does test a
# core dump regression in funcobject.c
del another.func_defaults
+
+def foo():
+ pass
+
+def bar():
+ pass
+
+def temp():
+ print 1
+
+if foo==bar: raise TestFailed
+
+d={}
+d[foo] = 1
+
+foo.func_code = temp.func_code
+
+d[foo]
+
diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py
index 5381e4d..31569d5 100644
--- a/Lib/test/test_opcodes.py
+++ b/Lib/test/test_opcodes.py
@@ -50,12 +50,12 @@ b = BClass()
try: raise AClass, b
except BClass, v:
- if v != b: raise TestFailed
-else: raise TestFailed
+ if v != b: raise TestFailed, "v!=b"
+else: raise TestFailed, "no exception"
try: raise b
except AClass, v:
- if v != b: raise TestFailed
+ if v != b: raise TestFailed, "v!=b AClass"
# not enough arguments
try: raise BClass, a
@@ -64,21 +64,21 @@ except TypeError: pass
try: raise DClass, a
except DClass, v:
if not isinstance(v, DClass):
- raise TestFailed
+ raise TestFailed, "v not DClass"
print '2.3 comparing function objects'
f = eval('lambda: None')
g = eval('lambda: None')
-if f != g: raise TestFailed
+if f == g: raise TestFailed, "functions should not be same"
f = eval('lambda a: a')
g = eval('lambda a: a')
-if f != g: raise TestFailed
+if f == g: raise TestFailed, "functions should not be same"
f = eval('lambda a=1: a')
g = eval('lambda a=1: a')
-if f != g: raise TestFailed
+if f == g: raise TestFailed, "functions should not be same"
f = eval('lambda: 0')
g = eval('lambda: 1')