Skip to content

Commit

Permalink
Only reactive some color tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeldycke committed Jan 28, 2025
1 parent 5452d8e commit c1fab2f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
> This version is not released yet and is under active development.
- Re-release to fix Github publishing.
- Reactivates some color tests on Windows.

## [4.13.1 (2025-01-28)](https://github.com/kdeldycke/click-extra/compare/v4.13.0...v4.13.1)

Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@

from __future__ import annotations

from extra_platforms.pytest import skip_windows # type: ignore[attr-defined]

from click_extra.pytest import create_config, extra_runner, invoke # noqa: F401

skip_windows_colors = skip_windows(reason="Click overstrip colors on Windows")
"""Skips color tests on Windows as ``click.testing.invoke`` overzealously strips colors.
See:
- https://github.com/pallets/click/issues/2111
- https://github.com/pallets/click/issues/2110
"""
2 changes: 2 additions & 0 deletions tests/test_colorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
default_options_colored_help,
)

from .conftest import skip_windows_colors


def test_theme_definition():
Expand Down Expand Up @@ -506,6 +507,7 @@ def command4():
assert not result.stderr


@skip_windows_colors
@parametrize("option_decorator", (color_option, color_option()))
@pytest.mark.parametrize(
("param", "expecting_colors"),
Expand Down
3 changes: 3 additions & 0 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
default_debug_uncolored_logging,
)

from .conftest import skip_windows_colors


def test_level_default_order():
assert tuple(LOG_LEVELS) == ("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG")
Expand Down Expand Up @@ -129,6 +131,7 @@ def logging_cli1():
)


@skip_windows_colors
@pytest.mark.parametrize(
"cmd_decorator",
# Skip click extra's commands, as verbosity option is already part of the default.
Expand Down
6 changes: 1 addition & 5 deletions tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import click
import pytest
from extra_platforms import is_windows
from pytest_cases import fixture, parametrize

from click_extra import Style, command, echo, pass_context, secho, style
Expand Down Expand Up @@ -221,10 +220,7 @@ def test_invoke_color_keep(invoke):
"""On Windows Click ends up deciding it is not running in an interactive terminal
and forces the stripping of all colors."""
result = invoke(run_cli1, color=True)
if is_windows():
check_default_uncolored_rendering(result)
else:
check_default_colored_rendering(result)
check_default_colored_rendering(result)
assert result.stdout.endswith(
"Context.color = None\nclick.utils.should_strip_ansi = False\n",
)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
default_debug_colored_version_details,
)

from .conftest import skip_windows_colors


@skip_windows_colors
@parametrize("cmd_decorator", command_decorators())
@parametrize("option_decorator", (extra_version_option, extra_version_option()))
def test_standalone_version_option(invoke, cmd_decorator, option_decorator):
Expand All @@ -63,6 +66,7 @@ def standalone_option():
)


@skip_windows_colors
@parametrize("cmd_decorator", command_decorators())
@parametrize("option_decorator", (extra_version_option, extra_version_option()))
def test_debug_output(invoke, cmd_decorator, option_decorator):
Expand All @@ -87,6 +91,7 @@ def debug_output():
)


@skip_windows_colors
def test_set_version(invoke):
@click.group
@extra_version_option(version="1.2.3.4")
Expand All @@ -102,6 +107,7 @@ def color_cli2():
)


@skip_windows_colors
@parametrize("cmd_decorator", command_decorators(no_groups=True))
@parametrize(
"message, regex_stdout",
Expand Down Expand Up @@ -165,6 +171,7 @@ def color_reset():
assert result.output == strip_ansi(result.output)


@skip_windows_colors
@parametrize("cmd_decorator", command_decorators(no_groups=True))
def test_custom_message_style(invoke, cmd_decorator):
@cmd_decorator
Expand Down Expand Up @@ -236,6 +243,7 @@ def color_cli4():
)


@skip_windows_colors
def test_color_option_precedence(invoke):
"""--no-color has an effect on --version, if placed in the right order.
Expand Down

0 comments on commit c1fab2f

Please sign in to comment.