Changeset 5357

Show
Ignore:
Timestamp:
09/05/08 07:00:41 (4 months ago)
Author:
Gustavo
Message:

Made optional the definition of the SA engine to be used for the tests. If not set, DBTest will use the one defined in test.ini.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tg/testutil.py

    r5331 r5357  
    77from sqlalchemy.orm import clear_mappers 
    88 
     9from tg import config 
     10 
    911__all__ = ['DBTest'] 
    1012 
    1113 
    1214class DBTest(TestCase): 
    13     """The base class for testing models in TG2 Projects.""" 
     15    """The base class for testing models in TG2 Projects. 
     16     
     17    You should at least define C{model}. If you don't define C{database}, we'll 
     18    create an SQLAlchemy engine with the DB URI defined in test.ini. 
     19     
     20    """ 
    1421    model = None 
    1522    database = None 
     
    1724    def setUp(self): 
    1825        assert self.model != None, "Database test cases must define the model" 
    19         assert self.database != None, "Database test cases must define the "\ 
    20                                       "database" 
     26        if self.database is None: 
     27            self.database = config['pylons.app_globals'].sa_engine 
    2128        self.model.init_model(self.database) 
    2229        self.model.metadata.create_all(self.database)