Skip to content

Commit

Permalink
Merge pull request #1105 from sirosen/bugfix/autoenv-uppercase
Browse files Browse the repository at this point in the history
Ensure auto_envvar_prefix is always uppercased
  • Loading branch information
davidism committed Sep 13, 2018
2 parents 752c5e4 + 7dbf7df commit 3e17a3d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Unreleased
- Document that parameter names are lowercased by default. (`#1055`_)
- Subcommands that are named by the function now automatically have the underscore replaced with a dash. If you register a function named ``my_command`` it becomes ``my-command`` in the command line interface.
- Hide hidden commands and options from completion. (`#1058`_, `#1061`_)
- Fix issue where a lowercase ``auto_envvar_prefix`` would not be converted to uppercase. (`#1105`_)

.. _#202: https://github.com/pallets/click/issues/202
.. _#323: https://github.com/pallets/click/issues/323
Expand Down Expand Up @@ -197,6 +198,7 @@ Unreleased
.. _#1058: https://github.com/pallets/click/pull/1058
.. _#1059: https://github.com/pallets/click/pull/1059
.. _#1061: https://github.com/pallets/click/pull/1061
.. _#1105: https://github.com/pallets/click/pull/1105


Version 6.7
Expand Down
2 changes: 1 addition & 1 deletion click/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def __init__(self, command, parent=None, info_name=None, obj=None,
auto_envvar_prefix = '%s_%s' % (parent.auto_envvar_prefix,
self.info_name.upper())
else:
self.auto_envvar_prefix = auto_envvar_prefix.upper()
auto_envvar_prefix = auto_envvar_prefix.upper()
self.auto_envvar_prefix = auto_envvar_prefix

if color is None and parent is not None:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ def cmd(username):
assert 'lambda' not in result.output
assert '(current user)' in result.output


def test_toupper_envvar_prefix(runner):
@click.command()
@click.option('--arg')
def cmd(arg):
click.echo(arg)

result = runner.invoke(cmd, [], auto_envvar_prefix='test',
env={'TEST_ARG': 'foo'})
assert not result.exception
assert result.output == 'foo\n'


def test_nargs_envvar(runner):
@click.command()
@click.option('--arg', nargs=2)
Expand Down

0 comments on commit 3e17a3d

Please sign in to comment.