Skip to content

Commit

Permalink
Make command line deprecation warnings visible with test profile (#3665)
Browse files Browse the repository at this point in the history
The `deprecated_command` decorator was only printing the warning if the
profile was not a test profile. With `verdi devel tests` being
deprecated, typically run with a test profile, the warning was being
swallowed.

This change gave problems with a test of `verdi comment show` that
expected no output for no input, but now of course failed due to the
output of the deprecation. Since it is a deprecated command anyway I
simply remove the test.
  • Loading branch information
sphuber authored and giovannipizzi committed Dec 13, 2019
1 parent ba51ed6 commit 7895662
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
6 changes: 0 additions & 6 deletions aiida/backends/tests/cmdline/commands/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ def setUp(self):
self.cli_runner = CliRunner()
self.node = orm.Data().store()

def test_comment_show_simple(self):
"""Test simply calling the show command (without data to show)."""
result = self.cli_runner.invoke(cmd_comment.show, [], catch_exceptions=False)
self.assertEqual(result.output, '')
self.assertEqual(result.exit_code, 0)

def test_comment_show(self):
"""Test showing an existing comment."""
self.node.add_comment(COMMENT)
Expand Down
4 changes: 2 additions & 2 deletions aiida/cmdline/commands/cmd_devel.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ def devel_validate_plugins():
@verdi_devel.command('tests')
@click.argument('paths', nargs=-1, type=TestModuleParamType(), required=False)
@options.VERBOSE(help='Print the class and function name for each test.')
@decorators.deprecated_command("This command will be removed in aiida-core v2.0.0. Please run 'pytest' instead.")
@decorators.deprecated_command("This command has been removed in aiida-core v1.1.0. Please run 'pytest' instead.")
@decorators.with_dbenv()
def devel_tests(paths, verbose): # pylint: disable=unused-argument
"""Run the unittest suite or parts of it.
.. deprecated:: 1.1.0
Will be removed in `v2.0.0`.
Entry point will be completely removed in `v2.0.0`.
"""


Expand Down
10 changes: 3 additions & 7 deletions aiida/cmdline/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,11 @@ def mycommand():
def wrapper(wrapped, _, args, kwargs):
"""Echo a deprecation warning before doing anything else."""
from aiida.cmdline.utils import templates
from aiida.manage.configuration import get_config
from textwrap import wrap

profile = get_config().current_profile

if not profile.is_test_profile:
template = templates.env.get_template('deprecated.tpl')
width = 80
echo.echo(template.render(msg=wrap(message, width - 4), width=width))
template = templates.env.get_template('deprecated.tpl')
width = 80
echo.echo(template.render(msg=wrap(message, width - 4), width=width))

return wrapped(*args, **kwargs)

Expand Down

0 comments on commit 7895662

Please sign in to comment.