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
17 changes: 17 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# config file for `direnv`: https://direnv.net
# load the poetry virtual environment when entering the project directory

strict_env

if [[ ! -f "pyproject.toml" ]]; then
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to create one first.'
exit 2
fi

local VENV="$(poetry env info --path)"
if [[ -z $VENV || ! -d $VENV/bin ]]; then
log_error 'No poetry virtual environment found. Use `poetry install` to create one first.'
exit 2
fi

source_env "$VENV/bin/activate"
8 changes: 2 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ jobs:
strategy:
matrix:
include:
- python-version: "3.8"
toxfactor: py3.8
ignore-typecheck-outcome: true
ignore-test-outcome: false
- python-version: "3.9"
toxfactor: py3.9
ignore-typecheck-outcome: true
Expand All @@ -31,7 +27,7 @@ jobs:
toxfactor: py3.12
ignore-typecheck-outcome: true
ignore-test-outcome: false
- python-version: "3.13-dev"
- python-version: "3.13"
toxfactor: py3.13
ignore-typecheck-outcome: true
ignore-test-outcome: false
Expand All @@ -47,7 +43,7 @@ jobs:

- name: Install poetry
run: |
python -m pip install poetry==1.8.3
python -m pip install poetry==2.0.0
- name: Configure poetry
run: |
Expand Down
15 changes: 10 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 24.10.0
rev: 1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # frozen: 24.10.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: c235f5e450b4b84e58d114ed4c589cbf454175a3 # frozen: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
rev: ce40a160603ab0e7d9c627ae33d7ef3906e2d2b2 # frozen: v3.19.1
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]
- repo: https://github.com/python-poetry/poetry
rev: "f03d8f98781934df7910be5b6c14756e047ef432" # frozen: 2.0.0
hooks:
- id: poetry-check
args: ["--lock"]
29 changes: 27 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
Changelog
=========

All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.1.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.

Unreleased
----------
- Declare compatibility with python 3.13
- Drop support for pytest < 7.0.0.

Added
+++++
* Declare compatibility with python 3.13. Supported versions are now: 3.9, 3.10, 3.11, 3.12, 3.13.

Changed
+++++++
* Changelog format updated to follow `Keep a Changelog <https://keepachangelog.com/en/1.1.0/>`_.

Deprecated
++++++++++

Removed
+++++++
* Drop support for python 3.8. Supported versions are now: 3.9, 3.10, 3.11, 3.12, 3.13.
* Drop support for pytest < 7.0.0.

Fixed
+++++

Security
++++++++

2.7.0
----------
Expand Down
447 changes: 261 additions & 186 deletions poetry.lock

Large diffs are not rendered by default.

38 changes: 20 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[tool.poetry]
[project]
name = "pytest-factoryboy"
version = "2.7.0"
description = "Factory Boy support for pytest."
authors = ["Oleg Pidsadnyi <[email protected]>"]
maintainers = ["Alessio Bogon <[email protected]>"]
authors = [ { name = "Oleg Pidsadnyi", email= "[email protected]" } ]
maintainers = [ { name = "Alessio Bogon", email = "[email protected]" } ]
license = "MIT"
readme = "README.rst"
homepage = "https://pytest-factoryboy.readthedocs.io/"
documentation = "https://pytest-factoryboy.readthedocs.io/"
repository = "https://github.com/pytest-dev/pytest-factoryboy"

classifiers = [
"Development Status :: 6 - Mature",
"Intended Audience :: Developers",
Expand All @@ -20,37 +18,41 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.9"
dependencies = [
"inflection",
"factory_boy>=2.10.0",
"pytest>=7.0",
"typing_extensions",
"packaging",
]

[tool.poetry.plugins."pytest11"]
"pytest-factoryboy" = "pytest_factoryboy.plugin"
[project.urls]
homepage = "https://pytest-factoryboy.readthedocs.io/"
documentation = "https://pytest-factoryboy.readthedocs.io/"
repository = "https://github.com/pytest-dev/pytest-factoryboy"

[tool.poetry.dependencies]
python = ">=3.8"
inflection = "*"
factory_boy = ">=2.10.0"
pytest = ">=7.0"
typing_extensions = "*"
packaging = "*"
[project.entry-points."pytest11"]
"pytest-factoryboy" = "pytest_factoryboy.plugin"

[tool.poetry.group.dev.dependencies]
mypy = ">=1.4.1"
tox = ">=4.0.8"
coverage = {extras = ["toml"], version = ">=6.5.0"}

[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core (>=2.0.0, <3.0.0)"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 120
target-version = ["py38", "py39", "py310", "py311", "py312", "py313"]
target-version = ["py39", "py310", "py311", "py312", "py313"]

[tool.isort]
profile = "black"
Expand Down
15 changes: 1 addition & 14 deletions pytest_factoryboy/compat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import pathlib
import sys
from collections.abc import Sequence
from importlib.metadata import version

Expand All @@ -11,24 +9,13 @@

pytest_version = parse_version(version("pytest"))

__all__ = ("PostGenerationContext", "path_with_stem", "getfixturedefs")
__all__ = ("PostGenerationContext", "getfixturedefs")

try:
from factory.declarations import PostGenerationContext
except ImportError: # factory_boy < 3.2.0
from factory.builder import PostGenerationContext

if sys.version_info >= (3, 9):

def path_with_stem(path: pathlib.Path, stem: str) -> pathlib.Path:
return path.with_stem(stem)

else:

def path_with_stem(path: pathlib.Path, stem: str) -> pathlib.Path:
return path.with_name(stem + path.suffix)


if pytest_version.release >= (8, 1):

def getfixturedefs(fixturemanager: FixtureManager, fixturename: str, node: Node) -> Sequence[FixtureDef] | None:
Expand Down
18 changes: 3 additions & 15 deletions pytest_factoryboy/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,11 @@
import functools
import sys
import warnings
from collections.abc import Collection, Iterable, Iterator, Mapping
from dataclasses import dataclass
from inspect import signature
from types import MethodType
from typing import (
TYPE_CHECKING,
Any,
Callable,
Collection,
Generic,
Iterable,
Iterator,
Mapping,
Type,
TypeVar,
cast,
overload,
)
from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar, cast, overload

import factory
import factory.builder
Expand All @@ -39,7 +27,7 @@

from .plugin import Request as FactoryboyRequest

FactoryType: TypeAlias = Type[factory.Factory]
FactoryType: TypeAlias = type[factory.Factory]
F = TypeVar("F", bound=FactoryType)
T = TypeVar("T")
T_co = TypeVar("T_co", covariant=True)
Expand Down
3 changes: 2 additions & 1 deletion pytest_factoryboy/fixturegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import functools
import inspect
from typing import Callable, Collection, TypeVar
from collections.abc import Collection
from typing import Callable, TypeVar

import pytest
from typing_extensions import ParamSpec
Expand Down
10 changes: 6 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[tox]
distshare = {homedir}/.tox/distshare
envlist = py{3.8,3.9,3.10,3.11,3.12,3.13}-pytest{7.3,7.4,8.0,8.1,8.2,8.3,latest,main}
py{3.8,3.9,3.10,3.11}-pytest{7.0,7.1,7.2}
envlist = py{3.9,3.10,3.11,3.12,3.13}-pytest{7.3,7.4,8.0,8.1,8.2,8.3,latest,main}
py{3.9,3.10,3.11}-pytest{7.0,7.1,7.2}
mypy


[testenv]
parallel_show_output = true
commands = coverage run -m pytest {posargs:tests}
commands = coverage run -m pytest {posargs}
ignore_outcome =
pytestmain: True
deps =
pytestlatest: pytest
pytestmain: git+https://github.com/pytest-dev/pytest.git@main
Expand All @@ -23,6 +24,7 @@ deps =

coverage[toml]


[testenv:mypy]
allowlist_externals = mypy
commands = mypy {posargs:.}
Expand Down
Loading