Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,12 @@ updates:
open-pull-requests-limit: 1
cooldown:
default-days: 7
# oldest/ pins the minimum supported versions on purpose; keep Dependabot
# (version and security updates alike) from bumping them.
- package-ecosystem: pip
directory: "/oldest"
schedule:
interval: monthly
open-pull-requests-limit: 0
ignore:
- dependency-name: "*"
2 changes: 1 addition & 1 deletion .github/workflows/dockerised-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
inputs:
python-versions:
description: 'Supported python versions'
default: '["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]'
default: '["3.11", "3.12", "3.13", "3.14", "3.15"]'
required: false
type: string
postgresql:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/oldest-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
inputs:
python-versions:
description: 'Supported python versions'
default: '["3.10", "3.11", "3.12", "3.13", "3.14", "3.15", "pypy-3.11"]'
default: '["3.11", "3.12", "3.13", "3.14", "3.15", "pypy-3.11"]'
required: false
type: string
postgresql:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/single-postgres-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
inputs:
python-versions:
description: 'Supported python versions'
default: '["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]'
default: '["3.11", "3.12", "3.13", "3.14", "3.15"]'
required: false
type: string
postgresql:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/single-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
inputs:
python-versions:
description: 'Supported python versions'
default: '["3.10", "3.11", "3.12", "3.13", "3.14", "3.15", "pypy-3.11"]'
default: '["3.11", "3.12", "3.13", "3.14", "3.15", "pypy-3.11"]'
required: false
type: string
postgresql:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: $/.github/workflows/single-postgres.yml
with:
postgresql: 17
python-versions: '["3.11", "3.12", "3.13", "3.14", "3.15", "pypy-3.11"]'
python-versions: '["3.12", "3.13", "3.14", "3.15", "pypy-3.11"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
postgresql_16:
Expand All @@ -55,7 +55,7 @@ jobs:
uses: $/.github/workflows/single-postgres.yml
with:
postgresql: 16
python-versions: '["3.12", "3.13", "3.14", "3.15"]'
python-versions: '["3.13", "3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
postgresql_15:
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
with:
postgresql: 18
os: macos-latest
python-versions: '["3.12", "3.13", "3.14", "3.15"]'
python-versions: '["3.13", "3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
macos_postgres_17:
Expand All @@ -97,7 +97,7 @@ jobs:
with:
postgresql: 17
os: macos-latest
python-versions: '["3.12", "3.13", "3.14", "3.15"]'
python-versions: '["3.13", "3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
macos_postgres_16:
Expand All @@ -108,7 +108,7 @@ jobs:
with:
postgresql: 16
os: macos-latest
python-versions: '["3.13", "3.14", "3.15"]'
python-versions: '["3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
windows_postgres_17:
Expand All @@ -118,7 +118,7 @@ jobs:
uses: $/.github/workflows/single-postgres-windows.yml
with:
postgresql: 17
python-versions: '["3.12", "3.13", "3.14", "3.15"]'
python-versions: '["3.13", "3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
docker_postgresql_18:
Expand All @@ -137,7 +137,7 @@ jobs:
uses: $/.github/workflows/dockerised-postgres.yml
with:
postgresql: 17
python-versions: '["3.11", "3.12", "3.13", "3.14", "3.15"]'
python-versions: '["3.12", "3.13", "3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
docker_postgresql_16:
Expand All @@ -147,7 +147,7 @@ jobs:
uses: $/.github/workflows/dockerised-postgres.yml
with:
postgresql: 16
python-versions: '["3.12", "3.13", "3.14", "3.15"]'
python-versions: '["3.13", "3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
docker_postgresql_15:
Expand All @@ -157,7 +157,7 @@ jobs:
uses: $/.github/workflows/dockerised-postgres.yml
with:
postgresql: 15
python-versions: '["3.13", "3.14", "3.15"]'
python-versions: '["3.14", "3.15"]'
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
docker_postgresql_14:
Expand Down
1 change: 1 addition & 0 deletions newsfragments/+oldest-pytest.break.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Require pytest>=8.4, the lowest version compatible with the ``async`` extra (pytest-asyncio>=1.4).
1 change: 1 addition & 0 deletions newsfragments/1440.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for Python 3.15, drop support for Python 3.10
Comment thread
coderabbitai[bot] marked this conversation as resolved.
1 change: 1 addition & 0 deletions newsfragments/1444.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable UP and PYI ruff rulesets
2 changes: 1 addition & 1 deletion oldest/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest == 9.0.3
pytest == 8.4.0
port-for == 0.7.3
mirakuru == 2.6.0
psycopg == 3.0.0
Expand Down
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.rst"
keywords = [ "fixture", "postgresql", "pytest", "tests" ]
license = "LGPL-3.0-or-later"
license-files = [ "COPYING.lesser" ]
requires-python = ">=3.10"
requires-python = ">=3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
Expand All @@ -21,15 +21,15 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
]
dependencies = [ "mirakuru>=2.6.0", "packaging", "port-for>=0.7.3", "psycopg>=3.0.0", "pytest>=8.2" ]
dependencies = [ "mirakuru>=2.6.0", "packaging", "port-for>=0.7.3", "psycopg>=3.0.0", "pytest>=8.4" ]

[[project.authors]]
name = "Grzegorz Śliwiński"
Expand Down Expand Up @@ -73,7 +73,7 @@ module-root = ""
source-include = [ "CHANGES.rst" ]

[tool.ruff]
target-version = "py310"
target-version = "py311"
line-length = 120

[tool.ruff.lint]
Expand All @@ -84,6 +84,8 @@ select = [
"FBT", # flake8-boolean-trap
"I", # isort
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"UP", # pyupgrade
]

[tool.pyproject-fmt]
Expand All @@ -97,6 +99,7 @@ sub_table_spacing = "\n"
[tool.mypy]
ignore_missing_imports = false
follow_imports = "silent"
python_version = "3.11"
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
Expand Down
1 change: 0 additions & 1 deletion pytest_postgresql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2016 by Clearcode <http://clearcode.cc>
# and associates (see AUTHORS).

Expand Down
2 changes: 1 addition & 1 deletion pytest_postgresql/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""pytest-postgresql's exceptions."""

from typing import Iterable
from collections.abc import Iterable


class ExecutableMissingException(FileNotFoundError):
Expand Down
14 changes: 7 additions & 7 deletions pytest_postgresql/executors/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import tempfile
import time
from pathlib import Path
from typing import Any, Optional, TypeVar
from typing import Any, Self, TypeVar

from mirakuru import TCPExecutor
from mirakuru.exceptions import ProcessFinishedWithError, TimeoutExpired
Expand Down Expand Up @@ -101,7 +101,7 @@ def __init__(
dbname: str,
*,
shell: bool = False,
timeout: Optional[int] = 60,
timeout: int | None = 60,
sleep: float = 0.1,
user: str = "postgres",
password: str | None = None,
Expand Down Expand Up @@ -189,7 +189,7 @@ def maintenance_dbname(self) -> str:
"""
return "postgres"

def start(self: T) -> T:
def start(self) -> Self:
"""Add check for postgresql version before starting process."""
if self.version < self.MIN_SUPPORTED_VERSION:
raise PostgreSQLUnsupported(
Expand Down Expand Up @@ -298,13 +298,13 @@ def init_directory(self) -> None:
# remove old one if exists first.
self.clean_directory()
pgdata = str(Path(self.datadir).resolve())
options = ["--username=%s" % self.user]
options = [f"--username={self.user}"]

if self.password:
password_file = tempfile.NamedTemporaryFile(delete=False)
password_path = password_file.name
try:
options += ["--auth=password", "--pwfile=%s" % password_path]
options += ["--auth=password", f"--pwfile={password_path}"]
if hasattr(self.password, "encode"):
password = self.password.encode("utf-8")
else:
Expand Down Expand Up @@ -391,7 +391,7 @@ def check_subprocess(self) -> bool:
return self.running()
return super().check_subprocess()

def _windows_terminate_process(self, _sig: Optional[int] = None) -> None:
def _windows_terminate_process(self, _sig: int | None = None) -> None:
"""Terminate process on Windows.

:param _sig: Signal parameter (unused on Windows but included for consistency)
Expand Down Expand Up @@ -423,7 +423,7 @@ def _windows_terminate_process(self, _sig: Optional[int] = None) -> None:
e,
)

def stop(self: T, sig: Optional[int] = None, exp_sig: Optional[int] = None) -> T:
def stop(self, sig: int | None = None, exp_sig: int | None = None) -> Self:
"""Issue a stop request to executable."""
try:
subprocess.check_output(
Expand Down
3 changes: 2 additions & 1 deletion pytest_postgresql/factories/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# along with pytest-postgresql. If not, see <http://www.gnu.org/licenses/>.
"""Fixture factory for postgresql client."""

from typing import AsyncIterator, Callable, Iterator, cast
from collections.abc import AsyncIterator, Callable, Iterator
from typing import cast

import psycopg
import pytest
Expand Down
2 changes: 1 addition & 1 deletion pytest_postgresql/factories/noprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"""Fixture factory for existing postgresql server."""

import os
from collections.abc import Callable, Iterator
from pathlib import Path
from typing import Callable, Iterator

import pytest

Expand Down
2 changes: 1 addition & 1 deletion pytest_postgresql/factories/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import os.path
import platform
import tempfile
from collections.abc import Callable, Iterable, Iterator
from pathlib import Path
from typing import Callable, Iterable, Iterator

import port_for
import pytest
Expand Down
15 changes: 8 additions & 7 deletions pytest_postgresql/janitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import asyncio
import inspect
import warnings
from collections.abc import AsyncIterator, Callable, Iterator
from contextlib import asynccontextmanager, contextmanager
from pathlib import Path
from types import TracebackType
from typing import AsyncIterator, Callable, Iterator, Type, TypeVar
from typing import Self, TypeVar

import psycopg
import psycopg.sql as sql
Expand Down Expand Up @@ -204,14 +205,14 @@ def connect() -> Connection:
cur.close()
conn.close()

def __enter__(self: DatabaseJanitorType) -> DatabaseJanitorType:
def __enter__(self) -> Self:
"""Initialize Database Janitor."""
self.init()
return self

def __exit__(
self: DatabaseJanitorType,
exc_type: Type[BaseException] | None,
self,
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None:
Expand Down Expand Up @@ -322,14 +323,14 @@ async def connect() -> psycopg.AsyncConnection:
finally:
await conn.close()

async def __aenter__(self: AsyncDatabaseJanitorType) -> AsyncDatabaseJanitorType:
async def __aenter__(self) -> Self:
"""Initialize Async Database Janitor."""
await self.init()
return self

async def __aexit__(
self: AsyncDatabaseJanitorType,
exc_type: Type[BaseException] | None,
self,
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None:
Expand Down
5 changes: 3 additions & 2 deletions pytest_postgresql/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import importlib
import re
from collections.abc import Callable
from functools import partial
from pathlib import Path
from types import ModuleType
from typing import Any, Callable
from typing import Any

import psycopg

Expand All @@ -19,7 +20,7 @@
def sql(sql_filename: Path, **kwargs: Any) -> None:
"""Database loader for sql files."""
with psycopg.connect(**kwargs) as db_connection:
with open(sql_filename, "r") as _fd:
with open(sql_filename) as _fd:
with db_connection.cursor() as cur:
cur.execute(_fd.read())
db_connection.commit()
Expand Down
Loading
Loading