-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #649
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,7 @@ def strip_comments(line: str) -> str: | |
|
||
:return: Stripped line. | ||
""" | ||
res = COMMENT_RE.search(line) | ||
if res: | ||
if res := COMMENT_RE.search(line): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
line = line[: res.start()] | ||
return line.strip() | ||
|
||
|
@@ -189,7 +188,7 @@ def parse_feature(basedir: str, filename: str, encoding: str = "utf-8") -> Featu | |
scenario.examples.set_param_names([l for l in split_line(parsed_line) if l]) | ||
mode = types.EXAMPLE_LINE | ||
elif mode == types.EXAMPLE_LINE: | ||
scenario.examples.add_example([l for l in split_line(stripped_line)]) | ||
scenario.examples.add_example(list(split_line(stripped_line))) | ||
Comment on lines
-192
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
elif mode and mode not in (types.FEATURE, types.TAG): | ||
step = Step(name=parsed_line, type=mode, indent=line_indent, line_number=line_number, keyword=keyword) | ||
if feature.background and not scenario: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ def find_fixturedefs_for_step(step: Step, fixturemanager: FixtureManager, nodeid | |
"""Find the fixture defs that can parse a step.""" | ||
# happens to be that _arg2fixturedefs is changed during the iteration so we use a copy | ||
fixture_def_by_name = list(fixturemanager._arg2fixturedefs.items()) | ||
for i, (fixturename, fixturedefs) in enumerate(fixture_def_by_name): | ||
for fixturename, fixturedefs in fixture_def_by_name: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
for pos, fixturedef in enumerate(fixturedefs): | ||
step_func_context = getattr(fixturedef.func, "_pytest_bdd_step_context", None) | ||
if step_func_context is None: | ||
|
@@ -244,14 +244,11 @@ def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str | |
def collect_example_parametrizations( | ||
templated_scenario: ScenarioTemplate, | ||
) -> list[ParameterSet] | None: | ||
# We need to evaluate these iterators and store them as lists, otherwise | ||
# we won't be able to do the cartesian product later (the second iterator will be consumed) | ||
contexts = list(templated_scenario.examples.as_contexts()) | ||
if not contexts: | ||
if contexts := list(templated_scenario.examples.as_contexts()): | ||
return [pytest.param(context, id="-".join(context.values())) for context in contexts] | ||
else: | ||
return None | ||
|
||
return [pytest.param(context, id="-".join(context.values())) for context in contexts] | ||
Comment on lines
-247
to
-253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ):
|
||
|
||
|
||
def scenario( | ||
feature_name: str, scenario_name: str, encoding: str = "utf-8", features_base_dir=None | ||
|
@@ -263,7 +260,7 @@ def scenario( | |
:param str encoding: Feature file encoding. | ||
""" | ||
__tracebackhide__ = True | ||
scenario_name = str(scenario_name) | ||
scenario_name = scenario_name | ||
Comment on lines
-266
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
caller_module_path = get_caller_module_path() | ||
|
||
# Get the feature | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
LogBDDCucumberJSON._get_result
refactored with the following changes:remove-redundant-if
)