Skip to content

Commit 556c35a

Browse files
authored
fix(deps): Enable testing with latest click (#1204)
* fix(deps): Enable testing with latest click * chore(deps): Update poetry.lock * generator: Update to support click 8.2
1 parent d804409 commit 556c35a

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

packages/generator/poetry.lock

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/generator/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ classifiers = [
2121
[tool.poetry.dependencies]
2222
python = "^3.9"
2323
Mako = "^1.2.1"
24-
click = ">=8.1.3"
24+
click = [
25+
# When dropping support for Python 3.9, remove the version check from tests/conftest.py
26+
{version = ">=8.1.3,<8.2.0", python = ">=3.9,<3.10"},
27+
{version = ">=8.1.3", python = "^3.10"},
28+
]
2529
grpcio = "^1.49.1"
2630
protobuf = ">=4.21"
2731
black = ">=24.8.0"

packages/generator/tests/conftest.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
from __future__ import annotations
44

55
import functools
6+
import importlib.metadata
67
import pathlib
78
import sys
89
from collections.abc import Generator, Sequence
9-
from typing import Protocol
10+
from typing import Any, Protocol
1011

1112
import pytest
1213
from click.testing import CliRunner, Result
1314
from ni_measurement_plugin_sdk_service.discovery._support import (
1415
_get_registration_json_file_path,
1516
)
17+
from packaging.version import Version
1618

1719
import ni_measurement_plugin_sdk_generator.client as client_generator
1820
import ni_measurement_plugin_sdk_generator.plugin as plugin_generator
@@ -58,14 +60,22 @@ def pin_map_directory(test_assets_directory: pathlib.Path) -> pathlib.Path:
5860
@pytest.fixture(scope="session")
5961
def create_client() -> Generator[CliRunnerFunction]:
6062
"""Test fixture for calling client generator cli."""
61-
runner = CliRunner(mix_stderr=False)
63+
runner = _create_clirunner()
6264
yield functools.partial(runner.invoke, client_generator.create_client, standalone_mode=False)
6365

6466

6567
@pytest.fixture(scope="session")
6668
def create_measurement() -> Generator[CliRunnerFunction]:
6769
"""Test fixture for calling plugin generator cli."""
68-
runner = CliRunner(mix_stderr=False)
70+
runner = _create_clirunner()
6971
yield functools.partial(
7072
runner.invoke, plugin_generator.create_measurement, standalone_mode=False
7173
)
74+
75+
76+
def _create_clirunner() -> CliRunner:
77+
kwargs: dict[str, Any] = {}
78+
if Version(importlib.metadata.version("click")) < Version("8.2.0"):
79+
# mix_stderr was removed in click 8.2.
80+
kwargs["mix_stderr"] = False
81+
return CliRunner(**kwargs)

0 commit comments

Comments
 (0)