diff options
author | Guido van Rossum <guido@python.org> | 2006-08-24 21:29:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2006-08-24 21:29:26 (GMT) |
commit | dc5f6b232be9f669f78d627cdcacc07d2ba167af (patch) | |
tree | a82abef2401c1fae00c67a176dd66710bbddc2f3 /Lib/test | |
parent | 801f0d78b5582a325d489831b991adb873067e80 (diff) | |
download | cpython-dc5f6b232be9f669f78d627cdcacc07d2ba167af.zip cpython-dc5f6b232be9f669f78d627cdcacc07d2ba167af.tar.gz cpython-dc5f6b232be9f669f78d627cdcacc07d2ba167af.tar.bz2 |
Got test_mutants.py working. One set of changes was straightforward:
use __eq__ instead of __cmp__. The other change is unexplained:
with a random hash code as before, it would run forever; with a constant
hash code, it fails quickly.
This found a refcount bug in dict_equal() -- I wonder if that bug is
also present in 2.5...
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_mutants.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/test/test_mutants.py b/Lib/test/test_mutants.py index 39ea806..7fc9ba3 100644 --- a/Lib/test/test_mutants.py +++ b/Lib/test/test_mutants.py @@ -27,7 +27,7 @@ import os # ran it. Indeed, at the start, the driver never got beyond 6 iterations # before the test died. -# The dicts are global to make it easy to mutate them from within functions. +# The dicts are global to make it easy to mutate tham from within functions. dict1 = {} dict2 = {} @@ -88,15 +88,22 @@ class Horrid: # have any systematic relationship between comparison outcomes # (based on self.i and other.i) and relative position within the # hash vector (based on hashcode). - self.hashcode = random.randrange(1000000000) + # XXX This is no longer effective. + ##self.hashcode = random.randrange(1000000000) def __hash__(self): - return self.hashcode + ##return self.hashcode + return 42 def __eq__(self, other): maybe_mutate() # The point of the test. return self.i == other.i + def __ne__(self, other): + raise RuntimeError("I didn't expect some kind of Spanish inquisition!") + + __lt__ = __le__ = __gt__ = __ge__ = __ne__ + def __repr__(self): return "Horrid(%d)" % self.i @@ -133,7 +140,6 @@ def test_one(n): if verbose: print ".", c = dict1 == dict2 - XXX # Can't figure out how to make this work if verbose: print |