diff --git a/tests/test_context.py b/tests/test_context.py index d13d58f17..824da11a5 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -4,10 +4,12 @@ import pytest import click +from click import Context +from click import Option +from click import Parameter from click.core import ParameterSource -from click.decorators import help_option, pass_meta_key - -from click import Context, Parameter, Option +from click.decorators import help_option +from click.decorators import pass_meta_key def test_ensure_context_objects(runner): @@ -268,12 +270,12 @@ def foo(): [ pytest.param( ("--option-with-callback", "--force-exit"), - ['ExitingOption', 'NonExitingOption'], + ["ExitingOption", "NonExitingOption"], id="natural_order", ), pytest.param( ("--force-exit", "--option-with-callback"), - ['ExitingOption'], + ["ExitingOption"], id="eagerness_precedence", ), ], @@ -287,7 +289,6 @@ def test_multiple_eager_callbacks(runner, cli_args, expect): called = [] class NonExitingOption(Option): - def reset_state(self): called.append(self.__class__.__name__) @@ -300,9 +301,7 @@ def __init__(self, *args, **kwargs) -> None: kwargs.setdefault("callback", self.set_state) super().__init__(*args, **kwargs) - class ExitingOption(NonExitingOption): - def set_state(self, ctx: Context, param: Parameter, value: str) -> str: value = super().set_state(ctx, param, value) ctx.exit() @@ -368,7 +367,6 @@ def __init__(self, *args, **kwargs) -> None: kwargs.setdefault("callback", self.set_level) super().__init__(*args, **kwargs) - @click.command() @click.option("--debug-logger-name", is_eager=True, cls=DebugLoggerOption) @help_option() @@ -389,9 +387,10 @@ def messing_with_logger(ctx, debug_logger_name): click.echo("This will never be printed as we exited early") - # Call the CLI to mess with the custom logger. - result = runner.invoke(messing_with_logger, ["--debug-logger-name", "my_logger", "--help"]) + result = runner.invoke( + messing_with_logger, ["--debug-logger-name", "my_logger", "--help"] + ) assert called == [True]