Skip to content

Commit

Permalink
Merge pull request #51 from dwreeves/master
Browse files Browse the repository at this point in the history
SQLAlchemy 1.4 support
  • Loading branch information
jeancochrane authored Jul 23, 2021
2 parents c109469 + 2ffc7a9 commit ea5c5ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
python: [3.6.x, 3.7.x]
sqlalchemy: [1.2.*, 1.3.*]
sqlalchemy: [1.2.*, 1.3.*, 1.4.*]
services:
postgres:
image: postgres:11
Expand Down
2 changes: 1 addition & 1 deletion pytest_flask_sqlalchemy/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _engine(pytestconfig, request, _transaction, mocker):
# https://docs.sqlalchemy.org/en/latest/changelog/migration_13.html
if version.parse(sa.__version__) < version.parse('1.3'):
engine.contextual_connect.return_value = connection
else:
elif version.parse(sa.__version__) < version.parse('1.4'):
engine._contextual_connect.return_value = connection

# References to `Engine.dialect` should redirect to the Connection (this
Expand Down
12 changes: 5 additions & 7 deletions tests/_conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import sqlalchemy as sa
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from pytest_postgresql.factories import (init_postgresql_database,
drop_postgresql_database)
from pytest_postgresql.janitor import DatabaseJanitor

# Retrieve a database connection string from the shell environment
try:
Expand All @@ -33,11 +32,10 @@ def database(request):
pg_pass = DB_OPTS.get("password")
pg_db = DB_OPTS["database"]

init_postgresql_database(pg_user, pg_host, pg_port, pg_db, pg_pass)

@request.addfinalizer
def drop_database():
drop_postgresql_database(pg_user, pg_host, pg_port, pg_db, 9.6, pg_pass)
janitor = DatabaseJanitor(pg_user, pg_host, pg_port, pg_db, 9.6, pg_pass)
janitor.init()
yield
janitor.drop()


@pytest.fixture(scope='session')
Expand Down
11 changes: 5 additions & 6 deletions tests/test_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def test_missing_db_fixture(testdir):
import sqlalchemy as sa
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from pytest_postgresql.factories import (init_postgresql_database,
drop_postgresql_database)
from pytest_postgresql.janitor import DatabaseJanitor
# Retrieve a database connection string from the shell environment
try:
Expand All @@ -102,11 +101,11 @@ def database(request):
pg_pass = DB_OPTS.get("password")
pg_db = DB_OPTS["database"]
init_postgresql_database(pg_user, pg_host, pg_port, pg_db, pg_pass)
janitor = DatabaseJanitor(pg_user, pg_host, pg_port, pg_db, 9.6, pg_pass)
janitor.init()
yield
janitor.drop()
@request.addfinalizer
def drop_database():
drop_postgresql_database(pg_user, pg_host, pg_port, pg_db, 9.6, pg_pass)
@pytest.fixture(scope='session')
Expand Down

5 comments on commit ea5c5ee

@pulphix
Copy link

@pulphix pulphix commented on ea5c5ee Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jeancochrane,
do you have any data on releasing this?
F.

@jeancochrane
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay @pulphix! I should have time to release on Saturday.

@jeancochrane
Copy link
Owner Author

@jeancochrane jeancochrane commented on ea5c5ee Dec 6, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viconnex
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jeancochrane, do you have any idea of when it will be released ? is there any "no go" that prevents you from releasing ?

@jeancochrane
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viconnex @kunspire @pulphix Thanks for your patience, 1.1.0 has finally been released! https://pypi.org/project/pytest-flask-sqlalchemy/1.1.0/

Please sign in to comment.