[Zope-Checkins] CVS: Zope2 - BasicStorage.py:1.3
Jim Fulton
jim@digicool.com
Thu, 12 Apr 2001 19:33:52 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/ZODB/tests
In directory korak:/tmp/cvs-serv9830
Modified Files:
BasicStorage.py
Log Message:
There were some tests that tested for failure, but that didn't
recognize other valid failure modes.
--- Updated File BasicStorage.py in package Zope2/lib/python/ZODB --
--- BasicStorage.py 2001/04/11 22:02:15 1.2
+++ BasicStorage.py 2001/04/12 23:33:51 1.3
@@ -26,14 +26,36 @@
POSException.StorageTransactionError,
self._storage.store,
0, 0, 0, 0, Transaction())
- self.assertRaises(
- POSException.StorageTransactionError,
- self._storage.abortVersion,
- 0, Transaction())
- self.assertRaises(
- POSException.StorageTransactionError,
- self._storage.commitVersion,
- 0, 1, Transaction())
+
+ #JF# The following will fail two ways. UnitTest doesn't
+ #JF# help us here:
+ #JF# self.assertRaises(
+ #JF# POSException.StorageTransactionError,
+ #JF# self._storage.abortVersion,
+ #JF# 0, Transaction())
+
+ #JF# but we can do it another way:
+ try:
+ self._storage.abortVersion('dummy', Transaction())
+ except (POSException.StorageTransactionError,
+ POSException.VersionCommitError):
+ pass # test passed ;)
+ else:
+ assert 0, "Should have failed, invalid transaction."
+
+ #JF# ditto
+ #JF# self.assertRaises(
+ #JF# POSException.StorageTransactionError,
+ #JF# self._storage.commitVersion,
+ #JF# 0, 1, Transaction())
+ try:
+ self._storage.commitVersion('dummy', 'dummer', Transaction())
+ except (POSException.StorageTransactionError,
+ POSException.VersionCommitError):
+ pass # test passed ;)
+ else:
+ assert 0, "Should have failed, invalid transaction."
+
self.assertRaises(
POSException.StorageTransactionError,
self._storage.store,
--- Updated File BasicStorage.py in package Zope2 --
--- BasicStorage.py 2001/04/11 22:02:15 1.2
+++ BasicStorage.py 2001/04/12 23:33:51 1.3
@@ -26,14 +26,36 @@
POSException.StorageTransactionError,
self._storage.store,
0, 0, 0, 0, Transaction())
- self.assertRaises(
- POSException.StorageTransactionError,
- self._storage.abortVersion,
- 0, Transaction())
- self.assertRaises(
- POSException.StorageTransactionError,
- self._storage.commitVersion,
- 0, 1, Transaction())
+
+ #JF# The following will fail two ways. UnitTest doesn't
+ #JF# help us here:
+ #JF# self.assertRaises(
+ #JF# POSException.StorageTransactionError,
+ #JF# self._storage.abortVersion,
+ #JF# 0, Transaction())
+
+ #JF# but we can do it another way:
+ try:
+ self._storage.abortVersion('dummy', Transaction())
+ except (POSException.StorageTransactionError,
+ POSException.VersionCommitError):
+ pass # test passed ;)
+ else:
+ assert 0, "Should have failed, invalid transaction."
+
+ #JF# ditto
+ #JF# self.assertRaises(
+ #JF# POSException.StorageTransactionError,
+ #JF# self._storage.commitVersion,
+ #JF# 0, 1, Transaction())
+ try:
+ self._storage.commitVersion('dummy', 'dummer', Transaction())
+ except (POSException.StorageTransactionError,
+ POSException.VersionCommitError):
+ pass # test passed ;)
+ else:
+ assert 0, "Should have failed, invalid transaction."
+
self.assertRaises(
POSException.StorageTransactionError,
self._storage.store,