From 051f831518868bb3da89f265f130517538ecc104 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 26 Aug 2026 18:58:55 +0200 Subject: [PATCH] test!: remove global registration of pytest plugins Instead a conftest.py close to the test files needs to opt into using plugin hooks and fixtures. also remove some packaging leftover with initenv.sh --- chatmaild/pyproject.toml | 3 --- chatmaild/src/chatmaild/tests/conftest.py | 3 +++ cmdeploy/pyproject.toml | 3 --- cmdeploy/src/cmdeploy/__init__.py | 1 + cmdeploy/src/cmdeploy/tests/conftest.py | 2 ++ scripts/initenv.sh | 4 ++++ 6 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 chatmaild/src/chatmaild/tests/conftest.py create mode 100644 cmdeploy/src/cmdeploy/__init__.py diff --git a/chatmaild/pyproject.toml b/chatmaild/pyproject.toml index a5abce26..06ce31ee 100644 --- a/chatmaild/pyproject.toml +++ b/chatmaild/pyproject.toml @@ -27,9 +27,6 @@ chatmail-quota-expire = "chatmaild.expire:quota_expire_main" chatmail-fsreport = "chatmaild.fsreport:main" lastlogin = "chatmaild.lastlogin:main" -[project.entry-points.pytest11] -"chatmaild.testplugin" = "chatmaild.tests.plugin" - [tool.pytest.ini_options] addopts = "-v -ra --strict-markers" log_format = "%(asctime)s %(levelname)s %(message)s" diff --git a/chatmaild/src/chatmaild/tests/conftest.py b/chatmaild/src/chatmaild/tests/conftest.py new file mode 100644 index 00000000..9c31d954 --- /dev/null +++ b/chatmaild/src/chatmaild/tests/conftest.py @@ -0,0 +1,3 @@ +"""Opt in to the chatmaild fixtures, which are not registered globally.""" + +from chatmaild.tests.plugin import * # noqa: F403 diff --git a/cmdeploy/pyproject.toml b/cmdeploy/pyproject.toml index 0934fb34..272cb45a 100644 --- a/cmdeploy/pyproject.toml +++ b/cmdeploy/pyproject.toml @@ -27,9 +27,6 @@ dependencies = [ [project.scripts] cmdeploy = "cmdeploy.cmdeploy:main" -[project.entry-points.pytest11] -"cmdeploy.testplugin" = "cmdeploy.tests.plugin" - [tool.pytest.ini_options] addopts = "-v -ra --strict-markers" diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -0,0 +1 @@ + diff --git a/cmdeploy/src/cmdeploy/tests/conftest.py b/cmdeploy/src/cmdeploy/tests/conftest.py index 857e8ed6..68a2a72d 100644 --- a/cmdeploy/src/cmdeploy/tests/conftest.py +++ b/cmdeploy/src/cmdeploy/tests/conftest.py @@ -1,9 +1,11 @@ """Run the lua scripts we ship under lupa, which bundles Lua 5.4 like dovecot.""" import pytest +from chatmaild.tests.plugin import * # noqa: F403 from lupa import lua54 from cmdeploy.basedeploy import get_resource +from cmdeploy.tests.plugin import * # noqa: F403 class Lua: diff --git a/scripts/initenv.sh b/scripts/initenv.sh index d0e40a54..87c3df41 100755 --- a/scripts/initenv.sh +++ b/scripts/initenv.sh @@ -20,6 +20,10 @@ fi python3 -m venv --upgrade-deps venv +# an editable install puts src/ on sys.path, so a leftover egg-info there is +# found as a second distribution and keeps removed entry points registered +rm -rf chatmaild/src/*.egg-info cmdeploy/src/*.egg-info + venv/bin/pip install -e chatmaild venv/bin/pip install -e cmdeploy venv/bin/pip install sphinx sphinxcontrib-mermaid sphinx-autobuild furo # for building the docs