Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @pytest.fixture(scope="session", autouse=True)
- def create_test_database():
- url = str(database.url)
- create_engine(url)
- if database_exists(url):
- drop_database(url)
- create_database(url) # Create the test database.
- p = os.path.join(os.getcwd(), "alembic.ini")
- m = os.path.join(os.getcwd(), "migrations")
- alembic_config = Config(p) # Run the migrations.
- alembic_config.set_main_option("script_location", m)
- alembic_config.attributes["configure_logger"] = False
- logger.debug("About to run alembic upgrade in tests")
- command.upgrade(alembic_config, "head")
- yield # Run the tests.
- drop_database(url) # Drop the test database.
- logger.debug("Drop db end of session fixture")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement