def cleanup_db():
    testing_config = TestingConfig()
    db_host = testing_config.DB_HOST
    db_name = testing_config.DB_NAME
    engine = create_engine(f'postgresql://{db_host}')
    conn = engine.connect()
    try:
        conn.execution_options(
            isolation_level="AUTOCOMMIT").execute(f"CREATE DATABASE {db_name}")
    except Exception:
        pass
    rv = create_engine(f'postgresql://{db_host}/{db_name}')

    db.create_all(rv)
    yield rv

    db.drop_all(rv)
    rv.dispose()
Example #2
0
 def teardown():
     _db.drop_all()
     os.unlink(TEST_DB_PATH)
Example #3
0
def drop_db():
    db.drop_all()
    return "删除完毕"
 def tearDown(self):
     db.session.expunge_all()
     db.drop_all()
Example #5
0
def drop_db():
    db.drop_all()
    return "跑路"
Example #6
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()