Skip to content

Commit

Permalink
Fix formatting for new flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Jun 26, 2020
1 parent d63fa17 commit 86239df
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/radish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
each_rule,
each_scenario,
each_step,
for_all
for_all,
)
from radish.models import ( # noqa
Background,
Expand All @@ -40,13 +40,13 @@
ScenarioLoop,
ScenarioOutline,
Step,
Tag
Tag,
)
from radish.parser import FeatureFileParser # noqa
from radish.parsetyperegistry import ( # noqa
TypeBuilder,
custom_type,
register_custom_type
register_custom_type,
)
from radish.stepregistry import given, step, then, when # noqa
from radish.terrain import world # noqa
24 changes: 17 additions & 7 deletions src/radish/hookregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ class GeneratorHookImpl(HookImpl):
A Generator Hook uses a yield statement to separate
the `before` and `after` part of a Hook.
"""
def __init__(
self, what, func, on_tags, order, is_formatter=False, always=False
):

def __init__(self, what, func, on_tags, order, is_formatter=False, always=False):
super().__init__(what, None, func, on_tags, order, is_formatter, always)

self.generator = None
Expand All @@ -114,7 +113,11 @@ class HookRegistry:
DEFAULT_HOOK_ORDER = 100

GENERATOR_HOOK_NAMES = {
"for_all", "each_feature", "each_rule", "each_scenario", "each_step"
"for_all",
"each_feature",
"each_rule",
"each_scenario",
"each_step",
}

def __init__(self):
Expand Down Expand Up @@ -142,9 +145,14 @@ def register(
"""Register the given Hook for later execution"""
if inspect.isgeneratorfunction(func):
# the registered function is a generator hook
hook_impl = GeneratorHookImpl(what, func, on_tags, order, is_formatter, always)
hook_impl = GeneratorHookImpl(
what, func, on_tags, order, is_formatter, always
)

if hook_impl in self._hooks["before"][what] and hook_impl in self._hooks["after"][what]:
if (
hook_impl in self._hooks["before"][what]
and hook_impl in self._hooks["after"][what]
):
# NOTE: allow a Hook Implementation to be registered multiple times.
# This can happend when one hook module imports another in the same
# RADISH_BASEDIR.
Expand Down Expand Up @@ -328,4 +336,6 @@ def call(self, what, when, only_formatters, tagged_model, *args, **kwargs):
#: Holds a global instance of the HookRegistry which shall be used
# by all modules implementing Hooks.
registry = HookRegistry()
__all__ = registry.create_hook_decorators() + registry.create_generator_hook_decorators()
__all__ = (
registry.create_hook_decorators() + registry.create_generator_hook_decorators()
)
8 changes: 7 additions & 1 deletion tests/unit/test_hookregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ def test_hookregistry_module_should_have_global_hook_decorators():

def test_hookregistry_module_should_have_global_generator_hook_decorators():
# given & when
from radish.hookregistry import for_all, each_feature, each_rule, each_scenario, each_step
from radish.hookregistry import (
for_all,
each_feature,
each_rule,
each_scenario,
each_step,
)

# then
assert callable(for_all)
Expand Down

0 comments on commit 86239df

Please sign in to comment.