Merge pull request #5120 from blueyed/minor

A collection of minor code tweaks
This commit is contained in:
Daniel Hahler 2019-04-15 16:32:20 +02:00 committed by GitHub
commit 5530d3e15d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 40 deletions

View File

@ -179,7 +179,9 @@ class LFPlugin(object):
self.lastfailed[report.nodeid] = True
def pytest_collection_modifyitems(self, session, config, items):
if self.active:
if not self.active:
return
if self.lastfailed:
previously_failed = []
previously_passed = []
@ -203,9 +205,7 @@ class LFPlugin(object):
else: # --failedfirst
items[:] = previously_failed + previously_passed
noun = (
"failure" if self._previously_failed_count == 1 else "failures"
)
noun = "failure" if self._previously_failed_count == 1 else "failures"
suffix = " first" if self.config.getoption("failedfirst") else ""
self._report_status = "rerun previous {count} {noun}{suffix}".format(
count=self._previously_failed_count, suffix=suffix, noun=noun

View File

@ -282,7 +282,6 @@ class PytestPluginManager(PluginManager):
known_marks = {m.name for m in getattr(method, "pytestmark", [])}
for name in ("tryfirst", "trylast", "optionalhook", "hookwrapper"):
opts.setdefault(name, hasattr(method, name) or name in known_marks)
return opts

View File

@ -227,7 +227,7 @@ def pytest_collectreport(report):
def pytest_deselected(items):
""" called for test items deselected by keyword. """
""" called for test items deselected, e.g. by keyword. """
@hookspec(firstresult=True)

View File

@ -304,7 +304,7 @@ class MarkGenerator(object):
for line in self._config.getini("markers"):
# example lines: "skipif(condition): skip the given test if..."
# or "hypothesis: tests which use Hypothesis", so to get the
# marker name we we split on both `:` and `(`.
# marker name we split on both `:` and `(`.
marker = line.split(":")[0].split("(")[0].strip()
self._markers.add(marker)

View File

@ -453,10 +453,10 @@ class TerminalReporter(object):
progress_length = len(" [100%]")
self._progress_nodeids_reported.add(nodeid)
last_item = (
is_last_item = (
len(self._progress_nodeids_reported) == self._session.testscollected
)
if last_item:
if is_last_item:
self._write_progress_information_filling_space()
else:
w = self._width_of_current_line