def setUp(self): super(DbFixture, self).setUp() testresources.setUpResources( self.test, self.test.resources, testresources._get_result()) self.addCleanup( testresources.tearDownResources, self.test, self.test.resources, testresources._get_result() ) if not hasattr(self.test, 'db'): msg = "backend '%s' unavailable" % self.DRIVER if self.skip_on_unavailable_db: self.test.skip(msg) else: self.test.fail(msg) if self.test.SCHEMA_SCOPE: self.test.engine = self.test.transaction_engine self.test.sessionmaker = session.get_maker( self.test.transaction_engine) else: self.test.engine = self.test.db.engine self.test.sessionmaker = session.get_maker(self.test.engine) self.addCleanup(setattr, self.test, 'sessionmaker', None) self.addCleanup(setattr, self.test, 'engine', None) self.test.enginefacade = enginefacade._TestTransactionFactory( self.test.engine, self.test.sessionmaker, apply_global=True, synchronous_reader=True) self.addCleanup(self.test.enginefacade.dispose_global)
def _init_resources(self): testresources.setUpResources(self.test, self.test.resources, testresources._get_result()) self.addCleanup(testresources.tearDownResources, self.test, self.test.resources, testresources._get_result()) # unfortunately, fixtures won't let us call a skip() from # here. So the test has to check this also. # see https://github.com/testing-cabal/fixtures/issues/31 if hasattr(self.test, 'db'): self.engine = self.test.engine = self.test.db.engine
def _init_resources(self): testresources.setUpResources( self.test, self.test.resources, testresources._get_result()) self.addCleanup( testresources.tearDownResources, self.test, self.test.resources, testresources._get_result() ) # unfortunately, fixtures won't let us call a skip() from # here. So the test has to check this also. # see https://github.com/testing-cabal/fixtures/issues/31 if hasattr(self.test, 'db'): self.engine = self.test.engine = self.test.db.engine
def _setup_fixtures(self): testresources.setUpResources(self, self.resources, testresources._get_result()) self.addCleanup(testresources.tearDownResources, self, self.resources, testresources._get_result()) fixtures = self._instantiate_fixtures() for fixture in fixtures: self.useFixture(fixture) if not fixture._has_db_resource(): msg = fixture._get_db_resource_not_available_reason() if self.SKIP_ON_UNAVAILABLE_DB: self.skipTest(msg) else: self.fail(msg)
def _setup_fixtures(self): testresources.setUpResources( self, self.resources, testresources._get_result()) self.addCleanup( testresources.tearDownResources, self, self.resources, testresources._get_result() ) fixtures = self._instantiate_fixtures() for fixture in fixtures: self.useFixture(fixture) if not fixture._has_db_resource(): msg = fixture._get_db_resource_not_available_reason() if self.SKIP_ON_UNAVAILABLE_DB: self.skipTest(msg) else: self.fail(msg)
def setUp(self): super(DbFixture, self).setUp() testresources.setUpResources( self.test, self.test.resources, testresources._get_result()) self.addCleanup( testresources.tearDownResources, self.test, self.test.resources, testresources._get_result() ) if not hasattr(self.test, 'db'): self.test.skip("database '%s' unavailable" % self.DRIVER) if self.test.SCHEMA_SCOPE: self.test.engine = self.test.transaction_engine self.test.sessionmaker = session.get_maker( self.test.transaction_engine) else: self.test.engine = self.test.db.engine self.test.sessionmaker = session.get_maker(self.test.engine) self.addCleanup(setattr, self.test, 'sessionmaker', None) self.addCleanup(setattr, self.test, 'engine', None)
def tearDownResources(self): testresources.tearDownResources(self, self.resources, testresources._get_result())
def setUpResources(self): testresources.setUpResources(self, self.resources, testresources._get_result())
def tearDownResources(self): testresources.tearDownResources( self, self.resources, testresources._get_result())
def setUpResources(self): testresources.setUpResources( self, self.resources, testresources._get_result())
def setUp(self): TestCase.setUp(self) result = testresources._get_result() testresources.setUpResources(self, self.resources, result) self.addCleanup( testresources.tearDownResources, self, self.resources, result)