Skip to content

Commit

Permalink
Add handling for newer prompt-toolkit version
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbluca committed Apr 6, 2022
1 parent ab2aa5a commit f3bc041
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/integration/test_cmd.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import prompt_toolkit
import pytest
from dask import config as dask_config
from mock import MagicMock, patch
from packaging.version import parse as parseVersion
from prompt_toolkit.application import create_app_session
from prompt_toolkit.input import create_pipe_input
from prompt_toolkit.output import DummyOutput
from prompt_toolkit.shortcuts import PromptSession

from dask_sql.cmd import _meta_commands

_prompt_toolkit_version = parseVersion(prompt_toolkit.__version__)


@pytest.fixture(autouse=True, scope="function")
def mock_prompt_input():
pipe_input = create_pipe_input()
try:
with create_app_session(input=pipe_input, output=DummyOutput()):
yield pipe_input
finally:
pipe_input.close()
# TODO: remove if prompt-toolkit min version gets bumped
if _prompt_toolkit_version >= parseVersion("3.0.29"):
with create_pipe_input() as pipe_input:
with create_app_session(input=pipe_input, output=DummyOutput()):
yield pipe_input
else:
pipe_input = create_pipe_input()
try:
with create_app_session(input=pipe_input, output=DummyOutput()):
yield pipe_input
finally:
pipe_input.close()


def _feed_cli_with_input(
Expand Down

0 comments on commit f3bc041

Please sign in to comment.