Skip to content
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

Merged
merged 1 commit into from
Nov 12, 2023
Merged

Sourcery refactored master branch #649

merged 1 commit into from
Nov 12, 2023

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Nov 12, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

elif report.failed and step["failed"]:
elif report.failed:
Copy link
Author

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:

if config.option.generate_missing:
return show_missing_code(config)
return None # Make mypy happy
return show_missing_code(config) if config.option.generate_missing else None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function cmdline_main refactored with the following changes:

This removes the following comments ( why? ):

# Make mypy happy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo this

Comment on lines 182 to 184
scenario = getattr(item.obj, "__scenario__", None)
if scenario:
if scenario := getattr(item.obj, "__scenario__", None):
if scenario in scenarios:
scenarios.remove(scenario)
for step in scenario.steps:
fixturedefs = _find_step_fixturedef(fm, item, step=step)
if fixturedefs:
if fixturedefs := _find_step_fixturedef(fm, item, step=step):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _show_missing_code_main refactored with the following changes:

Comment on lines 61 to 94
else:
if rep.passed:
word_markup = {"green": True}
elif rep.failed:
word_markup = {"red": True}
elif rep.skipped:
word_markup = {"yellow": True}
elif rep.passed:
word_markup = {"green": True}
elif rep.failed:
word_markup = {"red": True}
elif rep.skipped:
word_markup = {"yellow": True}
feature_markup = {"blue": True}
scenario_markup = word_markup

if self.verbosity <= 0:
if (
self.verbosity > 0
and self.verbosity == 1
and hasattr(report, "scenario")
):
self.ensure_newline()
self._tw.write("Feature: ", **feature_markup)
self._tw.write(report.scenario["feature"]["name"], **feature_markup)
self._tw.write("\n")
self._tw.write(" Scenario: ", **scenario_markup)
self._tw.write(report.scenario["name"], **scenario_markup)
self._tw.write(" ")
self._tw.write(word, **word_markup)
self._tw.write("\n")
elif (
self.verbosity > 0
and self.verbosity == 1
or self.verbosity > 0
and self.verbosity > 1
and not hasattr(report, "scenario")
or self.verbosity <= 0
):
return super().pytest_runtest_logreport(rep)
elif self.verbosity == 1:
if hasattr(report, "scenario"):
self.ensure_newline()
self._tw.write("Feature: ", **feature_markup)
self._tw.write(report.scenario["feature"]["name"], **feature_markup)
self._tw.write("\n")
self._tw.write(" Scenario: ", **scenario_markup)
self._tw.write(report.scenario["name"], **scenario_markup)
self._tw.write(" ")
self._tw.write(word, **word_markup)
self._tw.write("\n")
else:
return super().pytest_runtest_logreport(rep)
elif self.verbosity > 1:
if hasattr(report, "scenario"):
self.ensure_newline()
self._tw.write("Feature: ", **feature_markup)
self._tw.write(report.scenario["feature"]["name"], **feature_markup)
self._tw.write("\n")
self._tw.write(" Scenario: ", **scenario_markup)
self._tw.write(report.scenario["name"], **scenario_markup)
self._tw.write("\n")
for step in report.scenario["steps"]:
self._tw.write(f" {step['keyword']} {step['name']}\n", **scenario_markup)
self._tw.write(" " + word, **word_markup)
self._tw.write("\n\n")
else:
return super().pytest_runtest_logreport(rep)
self.ensure_newline()
self._tw.write("Feature: ", **feature_markup)
self._tw.write(report.scenario["feature"]["name"], **feature_markup)
self._tw.write("\n")
self._tw.write(" Scenario: ", **scenario_markup)
self._tw.write(report.scenario["name"], **scenario_markup)
self._tw.write("\n")
for step in report.scenario["steps"]:
self._tw.write(f" {step['keyword']} {step['name']}\n", **scenario_markup)
self._tw.write(f" {word}", **word_markup)
self._tw.write("\n\n")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GherkinTerminalReporter.pytest_runtest_logreport refactored with the following changes:

Comment on lines 55 to 62
for prefix, _ in STEP_PREFIXES:
if line.startswith(prefix):
return prefix.strip(), line[len(prefix) :].strip()
return "", line
return next(
(
(prefix.strip(), line[len(prefix) :].strip())
for prefix, _ in STEP_PREFIXES
if line.startswith(prefix)
),
("", line),
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parse_line refactored with the following changes:

  • Use the built-in function next instead of a for-loop (use-next)

Comment on lines 118 to 116
if isinstance(step_name, StepParser):
return step_name

return string(step_name)
return step_name if isinstance(step_name, StepParser) else string(step_name)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_parser refactored with the following changes:

if self.stopped is None:
return 0

return self.stopped - self.started
return 0 if self.stopped is None else self.stopped - self.started
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StepReport.duration refactored with the following changes:

for i, (fixturename, fixturedefs) in enumerate(fixture_def_by_name):
for fixturename, fixturedefs in fixture_def_by_name:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_fixturedefs_for_step refactored with the following changes:

Comment on lines -247 to -253
# 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]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function collect_example_parametrizations refactored with the following changes:

This removes the following comments ( why? ):

# 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)

Comment on lines -266 to +263
scenario_name = str(scenario_name)
scenario_name = scenario_name
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function scenario refactored with the following changes:

Copy link

codecov bot commented Nov 12, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (fead99d) 95.56% compared to head (f1ba44c) 95.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #649      +/-   ##
==========================================
- Coverage   95.56%   95.56%   -0.01%     
==========================================
  Files          49       49              
  Lines        1783     1780       -3     
  Branches      194      193       -1     
==========================================
- Hits         1704     1701       -3     
  Misses         52       52              
  Partials       27       27              
Files Coverage Δ
src/pytest_bdd/gherkin_terminal_reporter.py 83.60% <100.00%> (ø)
src/pytest_bdd/parser.py 98.68% <100.00%> (-0.01%) ⬇️
src/pytest_bdd/scenario.py 92.97% <100.00%> (-0.04%) ⬇️
src/pytest_bdd/cucumber_json.py 95.00% <0.00%> (ø)
src/pytest_bdd/generation.py 90.42% <0.00%> (-0.11%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@youtux youtux merged commit cf679a9 into master Nov 12, 2023
11 of 13 checks passed
@youtux youtux deleted the sourcery/master branch November 12, 2023 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant