From b201d9a2cceabb6412b9d4b4abd325e25d423aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Wed, 21 Sep 2022 02:20:25 +0300 Subject: Fixed missing schema with the psycopg2 store fixture --- tests/conftest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index 7497b52..6b3de78 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -141,13 +141,17 @@ def sqlite_store() -> DataStore: @pytest.fixture def psycopg2_store() -> DataStore: + from sqlalchemy import text from sqlalchemy.future import create_engine from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore engine = create_engine("postgresql+psycopg2://postgres:secret@localhost/testdb") try: - yield SQLAlchemyDataStore(engine, schema="alter", start_from_scratch=True) + with engine.begin() as conn: + conn.execute(text("CREATE SCHEMA IF NOT EXISTS psycopg2")) + + yield SQLAlchemyDataStore(engine, schema="psycopg2", start_from_scratch=True) finally: engine.dispose() -- cgit v1.2.1