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

Add handling for newer prompt_toolkit versions in cmd tests #447

Merged
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
6 changes: 6 additions & 0 deletions dask_sql/_compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import pandas as pd
import prompt_toolkit
from packaging.version import parse as parseVersion

_pandas_version = parseVersion(pd.__version__)
_prompt_toolkit_version = parseVersion(prompt_toolkit.__version__)

FLOAT_NAN_IMPLEMENTED = _pandas_version >= parseVersion("1.2.0")
INT_NAN_IMPLEMENTED = _pandas_version >= parseVersion("1.0.0")

# TODO: remove if prompt-toolkit min version gets bumped
PIPE_INPUT_CONTEXT_MANAGER = _prompt_toolkit_version >= parseVersion("3.0.29")
19 changes: 13 additions & 6 deletions tests/integration/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@
from prompt_toolkit.output import DummyOutput
from prompt_toolkit.shortcuts import PromptSession

from dask_sql._compat import PIPE_INPUT_CONTEXT_MANAGER
from dask_sql.cmd import _meta_commands


@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 PIPE_INPUT_CONTEXT_MANAGER:
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