aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/tests/test_cli.py
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-06 18:18:01 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-06 18:18:01 +0300
commit01fbacb386809436dfa331780875aed72cb76118 (patch)
tree04c911ad96ff0523bd4d3e7a45c23cf2f2d7607d /contrib/python/prompt-toolkit/py3/tests/test_cli.py
parent48fb997d7f820a474b9094a72d9798a95ec612b7 (diff)
downloadydb-01fbacb386809436dfa331780875aed72cb76118.tar.gz
intermediate changes
ref:b4f892f3c2b06a356c155f73c27efc5661a7fb89
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/tests/test_cli.py')
-rw-r--r--contrib/python/prompt-toolkit/py3/tests/test_cli.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/contrib/python/prompt-toolkit/py3/tests/test_cli.py b/contrib/python/prompt-toolkit/py3/tests/test_cli.py
index 678bc52636..53d1e4f284 100644
--- a/contrib/python/prompt-toolkit/py3/tests/test_cli.py
+++ b/contrib/python/prompt-toolkit/py3/tests/test_cli.py
@@ -45,9 +45,7 @@ def _feed_cli_with_input(
if check_line_ending:
assert text.endswith("\r")
- inp = create_pipe_input()
-
- try:
+ with create_pipe_input() as inp:
inp.send_text(text)
session = PromptSession(
input=inp,
@@ -59,12 +57,9 @@ def _feed_cli_with_input(
key_bindings=key_bindings,
)
- result = session.prompt()
+ _ = session.prompt()
return session.default_buffer.document, session.app
- finally:
- inp.close()
-
def test_simple_text_input():
# Simple text input, followed by enter.
@@ -933,15 +928,12 @@ def test_accept_default():
"""
Test `prompt(accept_default=True)`.
"""
- inp = create_pipe_input()
-
- session = PromptSession(input=inp, output=DummyOutput())
- result = session.prompt(default="hello", accept_default=True)
- assert result == "hello"
-
- # Test calling prompt() for a second time. (We had an issue where the
- # prompt reset between calls happened at the wrong time, breaking this.)
- result = session.prompt(default="world", accept_default=True)
- assert result == "world"
-
- inp.close()
+ with create_pipe_input() as inp:
+ session = PromptSession(input=inp, output=DummyOutput())
+ result = session.prompt(default="hello", accept_default=True)
+ assert result == "hello"
+
+ # Test calling prompt() for a second time. (We had an issue where the
+ # prompt reset between calls happened at the wrong time, breaking this.)
+ result = session.prompt(default="world", accept_default=True)
+ assert result == "world"