[ZODB-Dev] Testing ZODB application

Antonio Beamud Montero antonio.beamud at linkend.com
Thu May 22 12:12:46 EDT 2003


Hi all:
  I have created an application with ZODB very easily. The problem is
when I try to create the test. I only can create one test. for example:

Collector is a class that has a BTree and serveral methods to manage it.
Also in the __init__ method of collector I create the storage, the db,
the connection and in the root I create a key,BTree pair.

def removefs(base):
    """Remove all files created by FileStorage with path base."""
    for ext in '', '.old', '.tmp', '.lock', '.index', '.pack':   
        path = base + ext
        try:
            os.remove(path)
        except os.error, err:
            if err[0] != errno.ENOENT:
                raise


class CollectorBaseTest(unittest.TestCase):
    def setUp(self):
        self.col = Collector()
        self.id = '230920'
        req = FullRequest(self.id)
        req.set_period_start('2003-05-06 05:00:00')
        req.set_period_end('2003-05-06 07:00:00')
        self.col.add(req)
        
    def tearDown(self):
        self.col.storage.close()
        removefs(DATA)

class FirstTest(CollectorBaseTest):
    def runTest(self):
        """Comprobando una peticisn simple"""
        t = self.col.request_by_id(self.id)
        assert str(t) == "OK"

class SecTest(CollectorBaseTest):
    def runTest(self):
        t = self.col.request_by_id('11111')
        assert str(t) == "Failure"

But when I try to run this suite of tests, it says for the second test
it can't open the Data.fs file when it try to init the collector
object... 

Can anybody help me?
I need to do something especial to run tests with ZODB?

Thanks.




-- 
Antonio Beamud Montero <antonio.beamud at linkend.com>




More information about the ZODB-Dev mailing list