Skip to content

Commit

Permalink
fix test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
dwreeves committed Oct 6, 2023
1 parent fbc617a commit 1a4affe
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
setup(
install_requires=["click>=7", "rich>=10.7.0", "importlib-metadata; python_version < '3.8'", "typing_extensions"],
extras_require={
"dev": ["pre-commit", "pytest", "flake8", "flake8-docstrings", "pytest-cov", "packaging", "types-setuptools"],
"dev": [
"mypy",
"pre-commit",
"pytest",
"flake8",
"flake8-docstrings",
"pytest-cov",
"packaging",
"types-setuptools",
],
},
)
4 changes: 2 additions & 2 deletions tests/fixtures/table_alignment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rich_click as click
from rich_click._compat_click import CLICK_IS_BEFORE_VERSION_8X
from rich_click._compat_click import CLICK_IS_BEFORE_VERSION_8X, CLICK_IS_VERSION_80

click.rich_click.STYLE_COMMANDS_TABLE_COLUMN_WIDTH_RATIO = (1, 2)

Expand Down Expand Up @@ -98,7 +98,7 @@ def auth() -> None:
print("Downloading")


if CLICK_IS_BEFORE_VERSION_8X:
if CLICK_IS_BEFORE_VERSION_8X and not CLICK_IS_VERSION_80:
cmd_dec = cli.command()
else:
cmd_dec = cli.command
Expand Down
45 changes: 42 additions & 3 deletions tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,21 @@ class ClickGroupWithRichCommandClass(click.Group):
"""


group_help_output = """
if rich_version.major == 12:
group_help_output = """
Usage: cli [OPTIONS] COMMAND [ARGS]...
Some help
╔════════════════════════════════════════════════════════╗
║ Header ║
╚════════════════════════════════════════════════════════╝
╭─ Options ────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────╯
"""
else:
group_help_output = """
Usage: cli [OPTIONS] COMMAND [ARGS]...
Some help
Expand All @@ -244,10 +258,26 @@ class ClickGroupWithRichCommandClass(click.Group):
@pytest.mark.parametrize(
("command_callable", "expected_command_type", "expected_help_output"),
[
pytest.param(lambda: command, RichCommand, command_help_output, id="command1"),
pytest.param(
lambda: command,
RichCommand,
command_help_output,
marks=pytest.mark.skipif(
click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0"
),
id="command1",
),
pytest.param(lambda: command(), RichCommand, command_help_output, id="command2"),
pytest.param(lambda: command("cli"), RichCommand, command_help_output, id="command3"),
pytest.param(lambda: group, RichGroup, group_help_output, id="group1"),
pytest.param(
lambda: group,
RichGroup,
group_help_output,
id="group1",
marks=pytest.mark.skipif(
click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0"
),
),
pytest.param(lambda: group(), RichGroup, group_help_output, id="group2"),
pytest.param(lambda: group("cli"), RichGroup, group_help_output, id="group3"),
pytest.param(lambda: click.command(cls=RichCommand), RichCommand, command_help_output, id="click_command1"),
Expand All @@ -261,6 +291,9 @@ class ClickGroupWithRichCommandClass(click.Group):
RichCommand,
command_help_output,
id="RichGroup1",
marks=pytest.mark.skipif(
click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0"
),
),
pytest.param(
lambda: RichGroup(name="grp", callback=lambda: None).command("cli"),
Expand All @@ -273,6 +306,9 @@ class ClickGroupWithRichCommandClass(click.Group):
RichCommand,
command_help_output,
id="ClickGroup1",
marks=pytest.mark.skipif(
click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0"
),
),
pytest.param(
lambda: ClickGroupWithRichCommandClass(name="grp", callback=lambda: None).command("cli"),
Expand All @@ -285,6 +321,9 @@ class ClickGroupWithRichCommandClass(click.Group):
RichGroup,
group_help_output,
id="ClickGroup3",
marks=pytest.mark.skipif(
click_version < version.parse("8.1.0"), reason="decorator must be called prior to click 8.1.0"
),
),
pytest.param(
lambda: ClickGroupWithRichCommandClass(name="grp", callback=lambda: None).group("cli"),
Expand Down

0 comments on commit 1a4affe

Please sign in to comment.