diff --git a/docs/database.rst b/docs/database.rst index 6d2a4363..c4410a6a 100644 --- a/docs/database.rst +++ b/docs/database.rst @@ -325,16 +325,12 @@ Put this into ``conftest.py``:: import pytest from django.db import connections - import psycopg2 - from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT + import psycopg def run_sql(sql): - conn = psycopg2.connect(database='postgres') - conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) - cur = conn.cursor() - cur.execute(sql) - conn.close() + with psycopg.connect(database='postgres') as conn: + conn.execute(sql) @pytest.fixture(scope='session') @@ -505,7 +501,7 @@ Put this in ``conftest.py``:: .. warning:: This snippet shows ``cursor().executescript()`` which is `sqlite` specific, for - other database engines this method might differ. For instance, psycopg2 uses + other database engines this method might differ. For instance, psycopg uses ``cursor().execute()``. diff --git a/pyproject.toml b/pyproject.toml index 6662774f..9f922dc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,7 +90,6 @@ files = [ module = [ "django.*", "configurations.*", - "psycopg2cffi.*", ] ignore_missing_imports = true diff --git a/pytest_django_test/settings_postgres.py b/pytest_django_test/settings_postgres.py index f1627146..d5d7227b 100644 --- a/pytest_django_test/settings_postgres.py +++ b/pytest_django_test/settings_postgres.py @@ -3,15 +3,6 @@ from .settings_base import * # noqa: F403 -# PyPy compatibility -try: - from psycopg2cffi import compat - - compat.register() -except ImportError: - pass - - DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", diff --git a/tests/conftest.py b/tests/conftest.py index 54a2e1f7..c8f485c1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -74,14 +74,6 @@ def django_pytester( """ import django - # Pypy compatibility - try: - from psycopg2cffi import compat - except ImportError: - pass - else: - compat.register() - DATABASES = %(db_settings)s DATABASE_ROUTERS = ['pytest_django_test.db_router.DbRouter'] diff --git a/tox.ini b/tox.ini index f2c2a9e4..c72b1f42 100644 --- a/tox.ini +++ b/tox.ini @@ -18,8 +18,7 @@ deps = mysql_myisam: mysqlclient==2.1.0 mysql_innodb: mysqlclient==2.1.0 - !pypy3-postgres: psycopg2-binary - pypy3-postgres: psycopg2cffi + postgres: psycopg[binary] coverage: coverage[toml] coverage: coverage-enable-subprocess