summaryrefslogtreecommitdiff
path: root/tests/test_commands.py
diff options
context:
space:
mode:
authorFooBarQuaxx <mabidi6@gmail.com>2016-11-07 14:32:21 +0300
committerLokiHokie <wpifer3@gatech.edu>2018-05-15 11:14:29 -0400
commit85d507685c7b6c90079c85dfacb51bb834a519e3 (patch)
treea726750943fa548cd1fa870df66229de766c83ec /tests/test_commands.py
parenta00e01845100ce2b3d5288a2b655aad260346361 (diff)
downloadclick-85d507685c7b6c90079c85dfacb51bb834a519e3.tar.gz
Added deprecation flag to commands
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r--tests/test_commands.py66
1 files changed, 16 insertions, 50 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py
index af58e7a..ee6006b 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -263,61 +263,27 @@ def test_unprocessed_options(runner):
]
-def test_subcommand_naming(runner):
- @click.group()
- def cli():
+def test_deprecated_in_help_messages(runner):
+ @click.command(deprecated=True)
+ def cmd_with_help():
+ """CLI HELP"""
pass
- @cli.command()
- def foo_bar():
- click.echo('foo-bar')
+ result = runner.invoke(cmd_with_help, ['--help'])
+ assert '(DEPRECATED)' in result.output
- result = runner.invoke(cli, ['foo-bar'])
- assert not result.exception
- assert result.output.splitlines() == ['foo-bar']
-
-
-def test_environment_variables(runner):
- @click.group()
- def cli():
+ @click.command(deprecated=True)
+ def cmd_without_help():
pass
- @cli.command()
- @click.option('--name', envvar='CLICK_NAME')
- def foo(name):
- click.echo(name)
-
- result = runner.invoke(cli, ['foo'], env={'CLICK_NAME': 'environment'})
+ result = runner.invoke(cmd_without_help, ['--help'])
+ assert '(DEPRECATED)' in result.output
- assert not result.exception
- assert result.output == 'environment\n'
+def test_deprecated_in_invocation(runner):
+ @click.command(deprecated=True)
+ def deprecated_cmd():
+ debug()
-# Ensures the variables are read in the following order:
-# 1. CLI
-# 2. Environment
-# 3. Defaults
-variable_precedence_testdata = [
- (['foo', '--name=cli'], {'CLICK_NAME': 'environment'}, 'cli\n'),
- (['foo'], {'CLICK_NAME': 'environment'}, 'environment\n'),
- (['foo'], None, 'defaults\n'),
-]
-
-
-@pytest.mark.parametrize("command,environment,expected",
- variable_precedence_testdata)
-def test_variable_precendence_00(runner, command, environment, expected):
- @click.group()
- def cli():
- pass
-
- @cli.command()
- @click.option('--name', envvar='CLICK_NAME')
- def foo(name):
- click.echo(name)
-
- defaults = {'foo': {'name': 'defaults'}}
- result = runner.invoke(cli, command, default_map=defaults, env=environment)
-
- assert not result.exception
- assert result.output == expected
+ result = runner.invoke(deprecated_cmd)
+ assert 'DeprecationWarning:' in result.output