Commit 2bdeec1b authored by Barry Warsaw's avatar Barry Warsaw

Reworked to use the ZODBTestBase class and the new mixin style of

creating test classes.
parent 18f51531
# Test creation of a brand new database, and insertion of root objects. # Test creation of a brand new database, and insertion of root objects.
import unittest import unittest
import test_create
from ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping
class BaseInsertMixin: class InsertMixin:
def checkIsEmpty(self): def checkIsEmpty(self):
assert not self._root.has_key('names') assert not self._root.has_key('names')
def checkNewInserts(self): def checkNewInserts(self):
from Persistence import PersistentMapping
self._root['names'] = names = PersistentMapping() self._root['names'] = names = PersistentMapping()
names['Warsaw'] = 'Barry' names['Warsaw'] = 'Barry'
names['Hylton'] = 'Jeremy' names['Hylton'] = 'Jeremy'
...@@ -19,21 +19,21 @@ class BaseInsertMixin: ...@@ -19,21 +19,21 @@ class BaseInsertMixin:
class FullNewInsertsTest(test_create.FullBaseFramework, BaseInsertMixin): class FullNewInsertsTest(ZODBTestBase, InsertMixin):
pass import Full
ConcreteStorage = Full.Full
class MinimalNewInsertsTest(test_create.MinimalBaseFramework, BaseInsertMixin): class MinimalNewInsertsTest(ZODBTestBase, InsertMixin):
pass import Minimal
ConcreteStorage = Minimal.Minimal
def suite(): def suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(MinimalNewInsertsTest('checkIsEmpty')) suite.addTest(unittest.makeSuite(MinimalNewInsertsTest, 'check'))
suite.addTest(MinimalNewInsertsTest('checkNewInserts')) suite.addTest(unittest.makeSuite(FullNewInsertsTest, 'check'))
suite.addTest(FullNewInsertsTest('checkIsEmpty'))
suite.addTest(FullNewInsertsTest('checkNewInserts'))
return suite return suite
......
...@@ -2,18 +2,16 @@ ...@@ -2,18 +2,16 @@
# storages, like transaction aborts and commits, changing objects, etc. # storages, like transaction aborts and commits, changing objects, etc.
# Doesn't test undo, versions, or packing. # Doesn't test undo, versions, or packing.
import os
import errno
import time import time
import unittest import unittest
import test_create
from ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping
class CommitAndRead(test_create.BaseFramework): class CommitAndRead:
def checkCommit(self): def checkCommit(self):
from Persistence import PersistentMapping
assert not self._root assert not self._root
names = self._root['names'] = PersistentMapping() names = self._root['names'] = PersistentMapping()
names['Warsaw'] = 'Barry' names['Warsaw'] = 'Barry'
...@@ -52,12 +50,12 @@ class CommitAndRead(test_create.BaseFramework): ...@@ -52,12 +50,12 @@ class CommitAndRead(test_create.BaseFramework):
class MinimalCommitAndRead(CommitAndRead): class MinimalCommitAndRead(ZODBTestBase, CommitAndRead):
import Minimal import Minimal
ConcreteStorage = Minimal.Minimal ConcreteStorage = Minimal.Minimal
class FullCommitAndRead(CommitAndRead): class FullCommitAndRead(ZODBTestBase, CommitAndRead):
import Full import Full
ConcreteStorage = Full.Full ConcreteStorage = Full.Full
...@@ -65,20 +63,8 @@ class FullCommitAndRead(CommitAndRead): ...@@ -65,20 +63,8 @@ class FullCommitAndRead(CommitAndRead):
def suite(): def suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
# On the Minimal storage suite.addTest(unittest.makeSuite(MinimalCommitAndRead, 'check'))
suite.addTest(MinimalCommitAndRead('checkCommit')) suite.addTest(unittest.makeSuite(FullCommitAndRead, 'check'))
suite.addTest(MinimalCommitAndRead('checkReadAfterCommit'))
suite.addTest(MinimalCommitAndRead('checkAbortAfterRead'))
suite.addTest(MinimalCommitAndRead('checkReadAfterCommit'))
for i in range(5):
suite.addTest(MinimalCommitAndRead('checkChangingCommits'))
# On the Full storage
suite.addTest(FullCommitAndRead('checkCommit'))
suite.addTest(FullCommitAndRead('checkReadAfterCommit'))
suite.addTest(FullCommitAndRead('checkAbortAfterRead'))
suite.addTest(FullCommitAndRead('checkReadAfterCommit'))
for i in range(5):
suite.addTest(FullCommitAndRead('checkChangingCommits'))
return suite return suite
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment