diff --git a/poetry.lock b/poetry.lock index 76ea62f..67c2e1d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -577,13 +577,13 @@ virtualenv = ">=20.10.0" [[package]] name = "prompt-toolkit" -version = "3.0.36" +version = "3.0.47" description = "Library for building powerful interactive command lines in Python" optional = false -python-versions = ">=3.6.2" +python-versions = ">=3.7.0" files = [ - {file = "prompt_toolkit-3.0.36-py3-none-any.whl", hash = "sha256:aa64ad242a462c5ff0363a7b9cfe696c20d55d9fc60c11fd8e632d064804d305"}, - {file = "prompt_toolkit-3.0.36.tar.gz", hash = "sha256:3e163f254bef5a03b146397d7c1963bd3e2812f0964bb9a24e6ec761fd28db63"}, + {file = "prompt_toolkit-3.0.47-py3-none-any.whl", hash = "sha256:0d7bfa67001d5e39d02c224b663abc33687405033a8c422d0d675a5a13361d10"}, + {file = "prompt_toolkit-3.0.47.tar.gz", hash = "sha256:1e1b29cb58080b1e69f207c893a1a7bf16d127a5c30c9d17a25a5d77792e5360"}, ] [package.dependencies] @@ -1104,4 +1104,4 @@ test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-it [metadata] lock-version = "2.0" python-versions = ">=3.8" -content-hash = "89d56b75b6d9ca1303b0561288d900531c89d84142b72a9c0dcbf9dff78da0ae" +content-hash = "8385e8cdfdc17a456d30af3d04c180715a5297a595567a5d1f2fe261b23f3dcf" diff --git a/pyproject.toml b/pyproject.toml index fada9db..92058ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ license = "MIT" [tool.poetry.dependencies] python = ">=3.8" -prompt_toolkit = ">=2.0,<=3.0.36" # once https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1726 is fixed, this can be changed to ">=2.0,<4.0" +prompt_toolkit = ">=2.0,<4.0" [tool.poetry.group.docs] optional = true diff --git a/tests/prompts/test_common.py b/tests/prompts/test_common.py index 3250079..13a93e2 100644 --- a/tests/prompts/test_common.py +++ b/tests/prompts/test_common.py @@ -1,8 +1,10 @@ +import asyncio from unittest.mock import Mock from unittest.mock import call import pytest from prompt_toolkit.document import Document +from prompt_toolkit.input.defaults import create_pipe_input from prompt_toolkit.output import DummyOutput from prompt_toolkit.styles import Attrs from prompt_toolkit.validation import ValidationError @@ -13,7 +15,6 @@ from questionary.prompts.common import InquirerControl from questionary.prompts.common import build_validator from questionary.prompts.common import print_formatted_text -from tests.utils import execute_with_input_pipe from tests.utils import prompt_toolkit_version @@ -72,7 +73,7 @@ def get_prompt_tokens(): ic = InquirerControl(["a", "b", "c"]) - def run(inp): + async def run(inp): inp.send_text("") layout = common.create_inquirer_layout( ic, get_prompt_tokens, input=inp, output=DummyOutput() @@ -86,7 +87,15 @@ def run(inp): == 1000000000000000000000000000001 ) - execute_with_input_pipe(run) + if prompt_toolkit_version < (3, 0, 29): + inp = create_pipe_input() + try: + return asyncio.run(run(inp)) + finally: + inp.close() + else: + with create_pipe_input() as inp: + asyncio.run(run(inp)) def test_prompt_highlight_coexist():