diff --git a/bitfield/types.py b/bitfield/types.py index d7f6d8f..84ac604 100644 --- a/bitfield/types.py +++ b/bitfield/types.py @@ -260,5 +260,6 @@ def get_label(self, flag): from django.db.backends.postgresql.base import Database Database.extensions.register_adapter(Bit, lambda x: Database.extensions.AsIs(int(x))) Database.extensions.register_adapter(BitHandler, lambda x: Database.extensions.AsIs(int(x))) -except ImproperlyConfigured: +# Ignore in psycopg3 where there is no Database.extensions nor any need to adapt types +except (ImproperlyConfigured, AttributeError): pass diff --git a/conftest.py b/conftest.py index c2d8f2b..fd29c77 100644 --- a/conftest.py +++ b/conftest.py @@ -21,7 +21,7 @@ def pytest_configure(config): if test_db == 'postgres': DATABASES['default'].update({ - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'ENGINE': 'django.db.backends.postgresql', 'USER': 'postgres', }) elif test_db == 'mysql': diff --git a/tox.ini b/tox.ini index 8eb37f0..24080f5 100644 --- a/tox.ini +++ b/tox.ini @@ -3,8 +3,9 @@ # Taken from: # https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django envlist = - py{38,39,310}-django{32,40,41}-{sqlite,postgres}, - py{38,39,310,311}-django{41}-{sqlite,postgres}, + py{38,39,310}-django{32,40,41}-{sqlite,postgres}-psycopg2, + py{38,39,310,311}-django{41,42}-{sqlite,postgres}-psycopg2, + py311-django42-postgres-psycopg3, [gh-actions] python = @@ -19,13 +20,16 @@ commands = passenv = DB deps = pytest - psycopg2-binary>=2.8 + psycopg2: psycopg2-binary>=2.8 + psycopg3: psycopg[binary]>=3.1 django32: Django>=3.2,<3.3 django32: pytest-django>=4.2 django40: Django>=4.0,<4.1 django40: pytest-django>=4.5 django41: Django>=4.1,<4.2 django41: pytest-django>=4.5 + django42: Django>=4.2,<4.3 + django42: pytest-django>=4.5 setenv = sqlite: DB=sqlite postgres: DB=postgres