Skip to content
Myr

Fix for string cast of MissingParameter

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by James Daley · committed by David Lord · parent 14fa50a · Browse files · 4 files+33 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+33 added−0 removed

  • tests:+18 added−0 removed
  • other:+15 added−0 removed

4 files+33 added−0 removed

modified:click/exceptions.py+13 added
150 unmodified lines
151 msg and '. ' or '.',152 msg or '',153 )154155 def __str__(self):156 if self.message is None:157 param_name = self.param.name if self.param else None158 return "missing parameter: {}".format(param_name)159 else:160 return self.message161162 if PY2:163 __unicode__ = __str__164165 def __str__(self):166 return self.__unicode__().encode("utf-8")167168169class NoSuchOption(UsageError):170 """Raised if click attempted to handle an option that does not171 exist.172
76 unmodified lines
modified:tests/test_arguments.py+9 added
201 unmodified lines
202 assert result.exit_code == 2203 assert 'Missing argument "ARG".' in result.output204205206def test_missing_argument_string_cast():207 ctx = click.Context(click.Command(""))208209 with pytest.raises(click.MissingParameter) as excinfo:210 click.Argument(["a"], required=True).full_process_value(ctx, None)211212 assert str(excinfo.value) == "missing parameter: a"213214215def test_implicit_non_required(runner):216 @click.command()217 @click.argument('f', default='test')218 def cli(f):
89 unmodified lines
modified:tests/test_options.py+9 added
319 unmodified lines
320 result = runner.invoke(cmd, ['-whatever=23'])321 assert result.output == '23\n'322323324def test_missing_option_string_cast():325 ctx = click.Context(click.Command(""))326327 with pytest.raises(click.MissingParameter) as excinfo:328 click.Option(['-a'], required=True).full_process_value(ctx, None)329330 assert str(excinfo.value) == "missing parameter: a"331332333def test_missing_choice(runner):334 @click.command()335 @click.option('--foo', type=click.Choice(['foo', 'bar']),336 required=True)
196 unmodified lines
modified:CHANGES.rst+2 added
38 unmodified lines
39- Fix ``TypeError`` raised when using bool flags and specifying40 ``type=bool``. :issue:`1287`41- Newlines in option help text are replaced with spaces before42 re-wrapping to avoid uneven line breaks. :issue:`834`43- ``MissingParameter`` exceptions are printable in the Python44 interpreter. :issue:`1139`454647Version 7.048-----------
540 unmodified lines