Add create_tables test option
This commit is contained in:
@@ -4,6 +4,12 @@ Changelog
|
|||||||
Here you can see the full list of changes between each SQLAlchemy-Utils release.
|
Here you can see the full list of changes between each SQLAlchemy-Utils release.
|
||||||
|
|
||||||
|
|
||||||
|
0.25.4 (2014-04-22)
|
||||||
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
- Added ExpressionParser
|
||||||
|
|
||||||
|
|
||||||
0.25.3 (2014-04-21)
|
0.25.3 (2014-04-21)
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
@@ -34,15 +34,17 @@ def get_locale():
|
|||||||
|
|
||||||
class TestCase(object):
|
class TestCase(object):
|
||||||
dns = 'sqlite:///:memory:'
|
dns = 'sqlite:///:memory:'
|
||||||
|
create_tables = True
|
||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
self.engine = create_engine(self.dns)
|
self.engine = create_engine(self.dns)
|
||||||
# self.engine.echo = True
|
self.engine.echo = True
|
||||||
self.connection = self.engine.connect()
|
self.connection = self.engine.connect()
|
||||||
self.Base = declarative_base()
|
self.Base = declarative_base()
|
||||||
|
|
||||||
self.create_models()
|
self.create_models()
|
||||||
sa.orm.configure_mappers()
|
sa.orm.configure_mappers()
|
||||||
|
if self.create_tables:
|
||||||
self.Base.metadata.create_all(self.connection)
|
self.Base.metadata.create_all(self.connection)
|
||||||
|
|
||||||
Session = sessionmaker(bind=self.connection)
|
Session = sessionmaker(bind=self.connection)
|
||||||
@@ -53,6 +55,7 @@ class TestCase(object):
|
|||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
aggregates.manager.reset()
|
aggregates.manager.reset()
|
||||||
self.session.close_all()
|
self.session.close_all()
|
||||||
|
if self.create_tables:
|
||||||
self.Base.metadata.drop_all(self.connection)
|
self.Base.metadata.drop_all(self.connection)
|
||||||
self.connection.close()
|
self.connection.close()
|
||||||
self.engine.dispose()
|
self.engine.dispose()
|
||||||
|
@@ -14,6 +14,8 @@ class MyExpressionParser(ExpressionParser):
|
|||||||
|
|
||||||
|
|
||||||
class TestExpressionParser(TestCase):
|
class TestExpressionParser(TestCase):
|
||||||
|
create_tables = False
|
||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
TestCase.setup_method(self, method)
|
TestCase.setup_method(self, method)
|
||||||
self.parser = MyExpressionParser(self.Category)
|
self.parser = MyExpressionParser(self.Category)
|
||||||
|
Reference in New Issue
Block a user