From: Tamir Duberstein <tamird@kernel.org>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
Tamir Duberstein <tamird@kernel.org>
Subject: [PATCH b4 v2 05/11] Fix tests under uv with complex git config
Date: Sun, 19 Apr 2026 12:00:00 -0400 [thread overview]
Message-ID: <20260419-ruff-check-v2-5-089dfb264501@kernel.org> (raw)
In-Reply-To: <20260419-ruff-check-v2-0-089dfb264501@kernel.org>
Add pytest-asyncio to the dev group so pytest can run async TUI
tests.
Pin git-filter-repo to unreleased commit 4697eeb for the multiline
git config parser fix requested in
https://github.com/newren/git-filter-repo/issues/638.
That parser fix is the only functional change since v2.47.0:
https://github.com/newren/git-filter-repo/compare/v2.47.0...4697eeb37b7c3c30b0492e344f6b89f7139cef26
Inject commit.gpgsign=false through the test fixture so synthetic git
commits do not hang on local GPG/pinentry configuration. Also disable
attestation through MAIN_CONFIG so tests keep the old can_patatt=false
behavior after patatt becomes an unconditional dependency.
As a drive-by, route the test b4 globals, pytest sentinel, and XDG
env overrides through monkeypatch so each test gets automatic
cleanup.
Add pytest to the CI script.
Signed-off-by: Tamir Duberstein <tamird@kernel.org>
---
ci.sh | 1 +
pyproject.toml | 6 ++++--
src/tests/conftest.py | 39 +++++++++++++++++++++++++++++----------
3 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/ci.sh b/ci.sh
index ddd4cff..7632e85 100755
--- a/ci.sh
+++ b/ci.sh
@@ -5,3 +5,4 @@ set -eu
uv run ruff format --check
uv run ruff check
uv run mypy .
+uv run pytest --durations=20
diff --git a/pyproject.toml b/pyproject.toml
index 0c4f024..959d168 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -24,7 +24,9 @@ classifiers = [
]
dependencies = [
"requests>=2.24,<3.0",
- "git-filter-repo>=2.30,<3.0",
+ # Use unreleased fix for multiline git config values.
+ # https://github.com/newren/git-filter-repo/issues/638
+ "git-filter-repo @ git+https://github.com/newren/git-filter-repo.git@4697eeb37b7c3c30b0492e344f6b89f7139cef26",
"dkimpy>=1.0,<2.0",
"patatt>=0.6,<2.0",
"ezgb>=0.1",
@@ -68,7 +70,7 @@ b4 = "b4.command:cmd"
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
filterwarnings = "ignore:.*(pyopenssl|invalid escape sequence).*:DeprecationWarning"
-norecursedirs = ["tests/helpers", "patatt"]
+norecursedirs = ["tests/helpers", "ezgb", "liblore", "patatt"]
log_file = "pytest.log"
log_file_level = "DEBUG"
log_file_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
diff --git a/src/tests/conftest.py b/src/tests/conftest.py
index 0825373..48b2573 100644
--- a/src/tests/conftest.py
+++ b/src/tests/conftest.py
@@ -1,3 +1,4 @@
+import copy
import os
import pathlib
import sys
@@ -9,20 +10,38 @@ import b4
@pytest.fixture(scope='function', autouse=True)
-def settestdefaults(tmp_path: pathlib.Path) -> None:
+def settestdefaults(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: pathlib.Path,
+) -> None:
topdir = b4.git_get_toplevel()
if topdir and topdir != os.getcwd():
os.chdir(topdir)
- b4.can_network = False
- b4.MAIN_CONFIG = dict(b4.DEFAULT_CONFIG)
- b4.USER_CONFIG = {
- 'name': 'Test Override',
- 'email': 'test-override@example.com',
- }
- os.environ['XDG_DATA_HOME'] = str(tmp_path)
- os.environ['XDG_CACHE_HOME'] = str(tmp_path)
+ monkeypatch.setattr(b4, 'can_network', False)
+ monkeypatch.setattr(
+ b4,
+ 'MAIN_CONFIG',
+ {
+ **copy.deepcopy(b4.DEFAULT_CONFIG),
+ 'attestation-policy': 'off',
+ },
+ )
+ monkeypatch.setattr(
+ b4,
+ 'USER_CONFIG',
+ {
+ 'name': 'Test Override',
+ 'email': 'test-override@example.com',
+ },
+ )
+ monkeypatch.setenv('XDG_DATA_HOME', str(tmp_path))
+ monkeypatch.setenv('XDG_CACHE_HOME', str(tmp_path))
+ git_config_count = int(os.environ.get('GIT_CONFIG_COUNT', '0'))
+ monkeypatch.setenv('GIT_CONFIG_COUNT', str(git_config_count + 1))
+ monkeypatch.setenv(f'GIT_CONFIG_KEY_{git_config_count}', 'commit.gpgsign')
+ monkeypatch.setenv(f'GIT_CONFIG_VALUE_{git_config_count}', 'false')
# This lets us avoid execvp-ing from inside b4 when testing
- sys._running_in_pytest = True # type: ignore[attr-defined]
+ monkeypatch.setattr(sys, '_running_in_pytest', True, raising=False)
@pytest.fixture(scope='function')
--
2.53.0
next prev parent reply other threads:[~2026-04-19 16:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-19 15:59 [PATCH b4 v2 00/11] Enable stricter local checks Tamir Duberstein
2026-04-19 15:59 ` [PATCH b4 v2 01/11] Add CI script Tamir Duberstein
2026-04-19 15:59 ` [PATCH b4 v2 02/11] Add ruff checks to CI Tamir Duberstein
2026-04-19 15:59 ` [PATCH b4 v2 03/11] Import dependencies unconditionally Tamir Duberstein
2026-04-19 15:59 ` [PATCH b4 v2 04/11] Add ruff format check to CI Tamir Duberstein
2026-04-19 18:06 ` Tamir Duberstein
2026-04-19 16:00 ` Tamir Duberstein [this message]
2026-04-19 16:00 ` [PATCH b4 v2 06/11] Fix typings in misc/ Tamir Duberstein
2026-04-19 16:00 ` [PATCH b4 v2 07/11] Enable mypy unreachable warnings Tamir Duberstein
2026-04-19 16:00 ` [PATCH b4 v2 08/11] Enable and fix pyright diagnostics Tamir Duberstein
2026-04-19 16:00 ` [PATCH b4 v2 09/11] Avoid duplicate map lookups Tamir Duberstein
2026-04-19 16:00 ` [PATCH b4 v2 10/11] Add ty and configuration Tamir Duberstein
2026-04-19 16:00 ` [PATCH b4 v2 11/11] Enable pyright strict mode Tamir Duberstein
2026-04-23 2:48 ` [PATCH b4 v2 00/11] Enable stricter local checks Konstantin Ryabitsev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260419-ruff-check-v2-5-089dfb264501@kernel.org \
--to=tamird@kernel.org \
--cc=konstantin@linuxfoundation.org \
--cc=tools@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox