def teardown_module(): fresh_metadata = get_metadata('fresh') fresh_metadata.drop_all() fresh_metadata.bind.dispose() metadata.drop_all() sqlalchemy_cleanup() if os.path.exists('freshtest.db'): os.unlink('freshtest.db') stop_server()
def setup_module(): global users_table, test_table, multi_table, fresh_multi_table config.update({ 'sqlalchemy.dburi': 'sqlite:///:memory:', 'fresh.dburi': 'sqlite:///freshtest.db', }) if os.path.exists('freshtest.db'): os.unlink('freshtest.db') fresh_metadata = get_metadata('fresh') if metadata.is_bound(): metadata.bind = None bind_metadata() metadata.bind.echo = True fresh_metadata.bind.echo = True users_table = Table("users", metadata, Column("user_id", Integer, primary_key=True), Column("user_name", String(40)), Column("password", String(10))) persons_table = Table("persons", metadata, Column("id", Integer, primary_key=True), Column("name", String(40))) addresses_table = Table("addresses", metadata, Column("id", Integer, primary_key=True), Column("address", String(40)), Column("city", String(40)), Column("person_id", Integer, ForeignKey(persons_table.c.id))) multi_table = Table('multi', metadata, Column('id', Integer, primary_key=True)) metadata.create_all() test_table = Table("test", fresh_metadata, Column("id", Integer, primary_key=True), Column("val", String(40))) fresh_multi_table = Table('multi', fresh_metadata, Column('id', Integer, primary_key=True)) fresh_metadata.create_all() mapper(User, users_table) mapper(Person, persons_table) mapper(Address, addresses_table, properties=dict( person=relation(Person, backref='addresses'))) mapper(Test, test_table) start_server()