Skip to content
Myr

test_compat.py

This file

Path

tests/test_compat.py

17 lines · 490 bytes · Python

Last changed by

Do not warn about callback changes until 3.0Armin Ronacherbefore adoption236e09c

History of this file

Take it

Changed parameter callback signature.Armin Ronacherbefore adoptionbda39db

lines 1–3why, one step back
1import click
23

Do not warn about callback changes until 3.0Armin Ronacherbefore adoption236e09c

lines 4–7why, one step back
4if click.__version__ >= '3.0':
5 def test_legacy_callbacks(runner):6 def legacy_callback(ctx, value):7 return value.upper()

Changed parameter callback signature.Armin Ronacherbefore adoptionbda39db

line 8why, one step back
8

Do not warn about callback changes until 3.0Armin Ronacherbefore adoption236e09c

lines 9–12why, one step back
9 @click.command()
10 @click.option('--foo', callback=legacy_callback)11 def cli(foo):12 click.echo(foo)

Changed parameter callback signature.Armin Ronacherbefore adoptionbda39db

line 13why, one step back
13

Do not warn about callback changes until 3.0Armin Ronacherbefore adoption236e09c

lines 14–17why, one step back
14 result = runner.invoke(cli, ['--foo', 'wat'])
15 assert result.exit_code == 016 assert 'WAT' in result.output17 assert 'Invoked legacy parameter callback' in result.output