Description: Fix the test suite with click 8.2
Forwarded: no
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2025-02-21

--- a/tests/e2e/test_cli.py
+++ b/tests/e2e/test_cli.py
@@ -1,11 +1,14 @@
 """Test the command line interface."""
 
+import functools
 import logging
 import os
 import re
+from importlib import metadata as imp_metadata
 from itertools import product
 from pathlib import Path
 from textwrap import dedent
+from typing import Tuple
 
 import py  # type: ignore
 import pytest
@@ -16,10 +19,28 @@
 from yamlfix.version import __version__
 
 
+@functools.lru_cache
+def _click_version() -> Tuple[int, int]:
+    """Try to determine the `click` library version."""
+    version_str = imp_metadata.version("click")
+    try:
+        majmin = tuple(int(part) for part in version_str.split(".")[:2])
+    except ValueError:
+        return 0, 0
+
+    try:
+        return majmin[0], majmin[1]
+    except IndexError:
+        return 0, 0
+
+
 @pytest.fixture(name="runner")
 def fixture_runner() -> CliRunner:
     """Configure the Click cli test runner."""
-    return CliRunner(mix_stderr=False)
+    if _click_version() >= (8, 2):
+        return CliRunner()
+    else:
+        return CliRunner(mix_stderr=False)
 
 
 def test_version(runner: CliRunner) -> None:
