aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/click/py3/tests/test_testing.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-01-08 16:55:48 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-01-08 17:08:25 +0300
commit9b668f4d12c7d6fc709ffc4ab3b87a7e8aef8e2f (patch)
tree2795579b13b11329bc8f9dc82b48d04a04023616 /contrib/python/click/py3/tests/test_testing.py
parent5487449624c89f51c526f9e6de269590a273ebec (diff)
downloadydb-9b668f4d12c7d6fc709ffc4ab3b87a7e8aef8e2f.tar.gz
Intermediate changes
commit_hash:f15cd769f87762d4807f0d4ae628b5dfb830bef5
Diffstat (limited to 'contrib/python/click/py3/tests/test_testing.py')
-rw-r--r--contrib/python/click/py3/tests/test_testing.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/contrib/python/click/py3/tests/test_testing.py b/contrib/python/click/py3/tests/test_testing.py
index 9f294b3a13..0d227f2a0a 100644
--- a/contrib/python/click/py3/tests/test_testing.py
+++ b/contrib/python/click/py3/tests/test_testing.py
@@ -5,7 +5,7 @@ from io import BytesIO
import pytest
import click
-from click._compat import WIN
+from click.exceptions import ClickException
from click.testing import CliRunner
@@ -184,7 +184,6 @@ def test_catch_exceptions():
assert result.exit_code == 1
-@pytest.mark.skipif(WIN, reason="Test does not make sense on Windows.")
def test_with_color():
@click.command()
def cli():
@@ -201,6 +200,26 @@ def test_with_color():
assert not result.exception
+def test_with_color_errors():
+ class CLIError(ClickException):
+ def format_message(self) -> str:
+ return click.style(self.message, fg="red")
+
+ @click.command()
+ def cli():
+ raise CLIError("Red error")
+
+ runner = CliRunner()
+
+ result = runner.invoke(cli)
+ assert result.output == "Error: Red error\n"
+ assert result.exception
+
+ result = runner.invoke(cli, color=True)
+ assert result.output == f"Error: {click.style('Red error', fg='red')}\n"
+ assert result.exception
+
+
def test_with_color_but_pause_not_blocking():
@click.command()
def cli():
@@ -321,7 +340,7 @@ def test_stderr():
assert result_mix.stdout == "stdout\nstderr\n"
with pytest.raises(ValueError):
- result_mix.stderr
+ result_mix.stderr # noqa B018
@click.command()
def cli_empty_stderr():