aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/click/py3/tests/test_utils.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_utils.py
parent5487449624c89f51c526f9e6de269590a273ebec (diff)
downloadydb-9b668f4d12c7d6fc709ffc4ab3b87a7e8aef8e2f.tar.gz
Intermediate changes
commit_hash:f15cd769f87762d4807f0d4ae628b5dfb830bef5
Diffstat (limited to 'contrib/python/click/py3/tests/test_utils.py')
-rw-r--r--contrib/python/click/py3/tests/test_utils.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/contrib/python/click/py3/tests/test_utils.py b/contrib/python/click/py3/tests/test_utils.py
index 656d2f9e53..45433c6790 100644
--- a/contrib/python/click/py3/tests/test_utils.py
+++ b/contrib/python/click/py3/tests/test_utils.py
@@ -36,9 +36,7 @@ def test_echo(runner):
def test_echo_custom_file():
- import io
-
- f = io.StringIO()
+ f = StringIO()
click.echo("hello", file=f)
assert f.getvalue() == "hello\n"
@@ -181,7 +179,6 @@ def _test_gen_func():
yield "abc"
-@pytest.mark.skipif(WIN, reason="Different behavior on windows.")
@pytest.mark.parametrize("cat", ["cat", "cat ", "cat "])
@pytest.mark.parametrize(
"test",
@@ -209,7 +206,6 @@ def test_echo_via_pager(monkeypatch, capfd, cat, test):
assert out == expected_output
-@pytest.mark.skipif(WIN, reason="Test does not make sense on Windows.")
def test_echo_color_flag(monkeypatch, capfd):
isatty = True
monkeypatch.setattr(click._compat, "isatty", lambda x: isatty)
@@ -232,16 +228,23 @@ def test_echo_color_flag(monkeypatch, capfd):
assert out == f"{styled_text}\n"
isatty = False
- click.echo(styled_text)
- out, err = capfd.readouterr()
- assert out == f"{text}\n"
+ # Faking isatty() is not enough on Windows;
+ # the implementation caches the colorama wrapped stream
+ # so we have to use a new stream for each test
+ stream = StringIO()
+ click.echo(styled_text, file=stream)
+ assert stream.getvalue() == f"{text}\n"
+
+ stream = StringIO()
+ click.echo(styled_text, file=stream, color=True)
+ assert stream.getvalue() == f"{styled_text}\n"
def test_prompt_cast_default(capfd, monkeypatch):
monkeypatch.setattr(sys, "stdin", StringIO("\n"))
value = click.prompt("value", default="100", type=int)
capfd.readouterr()
- assert type(value) is int
+ assert type(value) is int # noqa E721
@pytest.mark.skipif(WIN, reason="Test too complex to make work windows.")
@@ -464,7 +467,7 @@ def test_expand_args(monkeypatch):
assert user in click.utils._expand_args(["~"])
monkeypatch.setenv("CLICK_TEST", "hello")
assert "hello" in click.utils._expand_args(["$CLICK_TEST"])
- #assert "setup.cfg" in click.utils._expand_args(["*.cfg"])
+ #assert "pyproject.toml" in click.utils._expand_args(["*.toml"])
#assert os.path.join("docs", "conf.py") in click.utils._expand_args(["**/conf.py"])
assert "*.not-found" in click.utils._expand_args(["*.not-found"])
# a bad glob pattern, such as a pytest identifier, should return itself