def test_connect_test_database(database_url):
    metadata1 = MetaData()
    Table('table', metadata1, Column('column1', Integer, primary_key=True))
    Table('table2', metadata1, Column('fk_column', ForeignKey('table.column1', name='fk_1')))
    with connect_test_database(database_url) as connection:
        metadata1.create_all(connection)

    metadata2 = MetaData()
    Table('table', metadata2, Column('column2', Unicode(20)))
    with connect_test_database(database_url) as connection:
        metadata2.create_all(connection)
        metadata3 = MetaData(bind=connection, reflect=True)

    assert len(metadata3.tables) == 1

    table = metadata3.tables['table']
    assert len(table.columns) == 1
    assert 'column2' in table.columns.keys()
def connection():
    with closing(connect_test_database('sqlite:///')) as connection:
        connection.execute('CREATE TABLE foo (id INTEGER PRIMARY KEY)')
        yield connection