Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeldycke committed Feb 23, 2024
1 parent d559076 commit 10197fd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/test_context.py
Expand Up @@ -281,7 +281,8 @@ def foo():
],
)
def test_multiple_eager_callbacks(runner, cli_args, expect):
"""Checks all callbacks are called on exit, even the nasty ones hidden within callbacks.
"""Checks all callbacks are called on exit, even the nasty ones hidden within
callbacks.
Also checks the order in which they're called.
"""
Expand Down Expand Up @@ -323,7 +324,8 @@ def cli():
def test_no_state_leaks(runner):
"""Demonstrate state leaks with a specific case of the generic test above.
Use a logger as a real-world example of a common fixture which, due to its global nature, can leak state if not clean-up properly in a callback.
Use a logger as a real-world example of a common fixture which, due to its global
nature, can leak state if not clean-up properly in a callback.
"""
# Keeps track of callback calls.
called = []
Expand Down Expand Up @@ -354,8 +356,9 @@ def set_level(self, ctx: Context, param: Parameter, value: str) -> None:
# Get the global logger object.
logger = logging.getLogger(self.logger_name)

# Check pre-conditions: new logger is not set, but inherits its level from default <root> logger.
# That's the exact same state we are expecting our logger to be in after being messed with by the CLI.
# Check pre-conditions: new logger is not set, but inherits its level from
# default <root> logger. That's the exact same state we are expecting our
# logger to be in after being messed with by the CLI.
assert logger.level == logging.NOTSET
assert logger.getEffectiveLevel() == logging.WARNING

Expand Down Expand Up @@ -394,7 +397,8 @@ def messing_with_logger(ctx, debug_logger_name):

assert called == [True]

# Check the custom logger has been reverted to it initial state by the option callback after being messed with by the CLI.
# Check the custom logger has been reverted to it initial state by the option
# callback after being messed with by the CLI.
logger = logging.getLogger("my_logger")
assert logger.level == logging.NOTSET
assert logger.getEffectiveLevel() == logging.WARNING
Expand Down

0 comments on commit 10197fd

Please sign in to comment.