Files
nixpkgs/pkgs/development/python-modules/flask/pytest-9.1-compat.patch

72 lines
2.2 KiB
Diff

From 498f13135acdf045c40bad193ec44c94277f32fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <tomas.hrnciar@me.com>
Date: Thu, 2 Jul 2026 09:03:11 +0200
Subject: [PATCH] Fix pytest >= 9.1 compatibility
pytest 9.1 removed the private `notset` sentinel from `_pytest.monkeypatch` (now `NOTSET` in `_pytest.compat`).
Add compatibility shim in tests/test_cli.py
Fixes: #6071
Assisted-by: Claude Opus 4.6
---
tests/conftest.py | 17 +++++++++++------
tests/test_cli.py | 5 ++++-
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 0414b9e22f..ee00e270b8 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -4,6 +4,11 @@
import pytest
from _pytest import monkeypatch
+try:
+ _notset = monkeypatch.notset
+except AttributeError:
+ from _pytest.compat import NOTSET as _notset
+
from flask import Flask
from flask.globals import app_ctx as _app_ctx
@@ -16,15 +21,15 @@ def _standard_os_environ():
"""
mp = monkeypatch.MonkeyPatch()
out = (
- (os.environ, "FLASK_ENV_FILE", monkeypatch.notset),
- (os.environ, "FLASK_APP", monkeypatch.notset),
- (os.environ, "FLASK_DEBUG", monkeypatch.notset),
- (os.environ, "FLASK_RUN_FROM_CLI", monkeypatch.notset),
- (os.environ, "WERKZEUG_RUN_MAIN", monkeypatch.notset),
+ (os.environ, "FLASK_ENV_FILE", _notset),
+ (os.environ, "FLASK_APP", _notset),
+ (os.environ, "FLASK_DEBUG", _notset),
+ (os.environ, "FLASK_RUN_FROM_CLI", _notset),
+ (os.environ, "WERKZEUG_RUN_MAIN", _notset),
)
for _, key, value in out:
- if value is monkeypatch.notset:
+ if value is _notset:
mp.delenv(key, False)
else:
mp.setenv(key, value)
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 2a34088bd5..35467265c1 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -11,7 +11,10 @@
import click
import pytest
-from _pytest.monkeypatch import notset
+try:
+ from _pytest.monkeypatch import notset
+except ImportError:
+ from _pytest.compat import NOTSET as notset
from click.testing import CliRunner
from flask import Blueprint