Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to support prompt_toolkit >3.0.37 #347

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions tests/prompts/test_common.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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()
Expand All @@ -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():
Expand Down
Loading