From 68f9289d0856c9d8199c770c8a4a396fbb076cd6 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Mar 10 2021 13:36:21 +0000 Subject: [PATCH 1/3] Fix deprecation warnings --- diff --git a/tests/conftest.py b/tests/conftest.py index 58cfa35..49905ff 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,7 +35,7 @@ def db(app): return db -@pytest.yield_fixture +@pytest.fixture def session(db, monkeypatch): """Patch Flask-SQLAlchemy to use a specific connection""" connection = db.engine.connect() @@ -51,7 +51,7 @@ def session(db, monkeypatch): connection.close() -@pytest.yield_fixture +@pytest.fixture def client(app): """A Flask test client. An instance of :class:`flask.testing.TestClient` by default. From 92a71beb44aef285d251696f22dccef1afb05e23 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Mar 10 2021 13:36:21 +0000 Subject: [PATCH 2/3] Tests: Use in-memory database for tests by default --- diff --git a/tests/conftest.py b/tests/conftest.py index 49905ff..f12c7cd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,10 +26,11 @@ def db(app): # template1 database in special AUTOCOMMIT isolation level. dburl = copy(db.engine.url) dburl.database = 'template1' - with create_engine(dburl).connect() as connection: - connection.execution_options(isolation_level='AUTOCOMMIT') - connection.execute('DROP DATABASE IF EXISTS {}'.format(dbname)) - connection.execute('CREATE DATABASE {}'.format(dbname)) + if ':memory:' not in dbname: + with create_engine(dburl).connect() as connection: + connection.execution_options(isolation_level='AUTOCOMMIT') + connection.execute('DROP DATABASE IF EXISTS {}'.format(dbname)) + connection.execute('CREATE DATABASE {}'.format(dbname)) db.create_all() db_hook_event_listeners() return db diff --git a/waiverdb/config.py b/waiverdb/config.py index bea9b00..b4c4348 100644 --- a/waiverdb/config.py +++ b/waiverdb/config.py @@ -55,7 +55,7 @@ class TestingConfig(Config): TRAP_BAD_REQUEST_ERRORS = True # Beware that the tests constantly wipe and re-create this database! # Do not configure this to point at any data you care about! - DATABASE_URI = 'postgresql+psycopg2:///waiverdb_test' + DATABASE_URI = 'sqlite:///:memory:' TESTING = True OIDC_CLIENT_SECRETS = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'tests', From ef2f4cce170efb80d68cee57aba6c9dc109eb852 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Mar 10 2021 13:39:03 +0000 Subject: [PATCH 3/3] Tests: Use Python 3.8 for tox Python 3.8 is included in Fedora 32 which is the base container we use. --- diff --git a/tox.ini b/tox.ini index ad7458a..63a9eb0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = lint,py36,docs +envlist = lint,py38,docs # If the user is missing an interpreter, don't fail skip_missing_interpreters = True