Merge pull request #650 from pytest-dev/ab/sourcery-config

Add config file for Sourcery.ai
This commit is contained in:
Alessio Bogon 2023-11-12 23:16:52 +01:00 committed by GitHub
commit fead99df73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 37 deletions

4
.sourcery.yaml Normal file
View File

@ -0,0 +1,4 @@
rule_settings:
disable:
- "assign-if-exp"
- "use-next"

View File

@ -184,8 +184,7 @@ def _show_missing_code_main(config: Config, session: Session) -> None:
if scenario in scenarios:
scenarios.remove(scenario)
for step in scenario.steps:
fixturedefs = _find_step_fixturedef(fm, item, step=step)
if fixturedefs:
if _find_step_fixturedef(fm, item, step=step):
try:
steps.remove(step)
except ValueError:

View File

@ -58,45 +58,40 @@ class GherkinTerminalReporter(TerminalReporter):
if isinstance(word, tuple):
word, word_markup = word
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 or not hasattr(report, "scenario"):
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)
if self.verbosity == 1:
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 > 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(" " + word, **word_markup)
self._tw.write("\n\n")
self.stats.setdefault(cat, []).append(rep)
return None