[Zodb-checkins] CVS: StandaloneZODB/BTrees/tests - testConflict.py:1.8
Wed, 26 Sep 2001 18:07:23 -0400
Update of /cvs-repository/StandaloneZODB/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv7152
Be more specific about exception begin caugh in test_merge().
The only exceptions that an _p_resolveConflict() method should raise
are ConflictError and ValueError. If it raises a different exception,
then it has failed.
In general, a unittest should not use a bare except clause, because
they almost always mask failures. If the test really means to catch
all exceptions, it's best to make a comment to that effect.
=== StandaloneZODB/BTrees/tests/testConflict.py 1.7 => 1.8 ===
from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
+from ZODB.POSException import ConflictError
""" Tests common to all types: sets, buckets, and BTrees """
@@ -382,17 +384,18 @@
if expected is None: expected=((((),),),)
- try: merged=o1._p_resolveConflict(s1, s2, s3)
- except: pass # cool
- else: assert 0, message
+ merged=o1._p_resolveConflict(s1, s2, s3)
+ except (ConflictError, ValueError), err:
+ pass # ConflictError is the only exception that should occur
+ assert 0, message
merged=o1._p_resolveConflict(s1, s2, s3)
assert merged==expected, message
""" Tests common to all buckets """