| 1 |
From: Colin Watson <[email protected]> |
| 2 |
Date: Tue, 4 Mar 2025 10:13:55 +0000 |
| 3 |
Subject: Fix tests with Click 8.2 |
| 4 |
|
| 5 |
https://github.com/pallets/click/pull/2523 introduced changes to |
| 6 |
`click.testing` that broke a few unit tests in Flasgger: |
| 7 |
`mix_stderr=False` is now effectively the default and can no longer be |
| 8 |
specified explicitly. Although this Click version hasn't been fully |
| 9 |
released yet, this adjusts Flasgger to work with both old and new |
| 10 |
versions. |
| 11 |
|
| 12 |
Forwarded: https://github.com/flasgger/flasgger/pull/633 |
| 13 |
Bug-Debian: https://bugs.debian.org/1098599 |
| 14 |
Last-Update: 2025-03-04 |
| 15 |
--- |
| 16 |
tests/conftest.py | 8 +++++++- |
| 17 |
1 file changed, 7 insertions(+), 1 deletion(-) |
| 18 |
|
| 19 |
diff --git a/tests/conftest.py b/tests/conftest.py |
| 20 |
index bb83d68..5acb492 100644 |
| 21 |
--- a/tests/conftest.py |
| 22 |
+++ b/tests/conftest.py |
| 23 |
@@ -1,7 +1,9 @@ |
| 24 |
+import inspect |
| 25 |
import json |
| 26 |
import random |
| 27 |
|
| 28 |
import pytest |
| 29 |
+from click.testing import CliRunner |
| 30 |
from flasgger import Swagger |
| 31 |
from flasgger.utils import get_examples |
| 32 |
|
| 33 |
@@ -99,4 +101,8 @@ def app(): |
| 34 |
|
| 35 |
@pytest.fixture(scope="function") |
| 36 |
def cli_runner(app): |
| 37 |
- yield app.test_cli_runner(mix_stderr=False) |
| 38 |
+ kwargs = {} |
| 39 |
+ if "mix_stderr" in inspect.signature(CliRunner).parameters: |
| 40 |
+ # click < 8.2 |
| 41 |
+ kwargs["mix_stderr"] = False |
| 42 |
+ yield app.test_cli_runner(**kwargs) |