Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 23, 2024
1 parent 0ef5965 commit 22ea386
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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",
),
],
Expand All @@ -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__)

Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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]

Expand Down

0 comments on commit 22ea386

Please sign in to comment.