Skip to content
Myr

test_compat.py

This file

Path

tests/test_compat.py

35 lines · 1.1 KiB · Python

Last changed by

Merge pull request #1186 from RonnyPfannschmidt/jupyter-notebookDavid Lordbefore adoption65386d9

History of this file

Take it

1import click2import pytest3from click._compat import should_strip_ansi, WIN456def test_legacy_callbacks(runner):7    def legacy_callback(ctx, value):8        return value.upper()910    @click.command()11    @click.option('--foo', callback=legacy_callback)12    def cli(foo):13        click.echo(foo)1415    with pytest.warns(Warning, match='Invoked legacy parameter callback'):16        result = runner.invoke(cli, ['--foo', 'wat'])17        assert result.exit_code == 018        assert 'WAT' in result.output192021def test_bash_func_name():22    from click._bashcomplete import get_completion_script23    script = get_completion_script('foo-bar baz_blah', '_COMPLETE_VAR', 'bash').strip()24    assert script.startswith('_foo_barbaz_blah_completion()')25    assert '_COMPLETE_VAR=complete $1' in script262728@pytest.mark.xfail(WIN, reason="Jupyter not tested/supported on Windows")29def test_is_jupyter_kernel_output():30    class JupyterKernelFakeStream(object):31        pass3233    # implementation detail, aka cheapskate test34    JupyterKernelFakeStream.__module__ = "ipykernel.faked"35    assert not should_strip_ansi(stream=JupyterKernelFakeStream())