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()
def teardown(): _db.drop_all() os.unlink(TEST_DB_PATH)
def drop_db(): db.drop_all() return "删除完毕"
def tearDown(self): db.session.expunge_all() db.drop_all()
def drop_db(): db.drop_all() return "跑路"
def tearDown(self): db.session.remove() db.drop_all()