minor: LFPlugin: de-indent code by returning if not active
This commit is contained in:
parent
19035f4b55
commit
1d137fd2fe
|
@ -179,45 +179,45 @@ class LFPlugin(object):
|
||||||
self.lastfailed[report.nodeid] = True
|
self.lastfailed[report.nodeid] = True
|
||||||
|
|
||||||
def pytest_collection_modifyitems(self, session, config, items):
|
def pytest_collection_modifyitems(self, session, config, items):
|
||||||
if self.active:
|
if not self.active:
|
||||||
if self.lastfailed:
|
return
|
||||||
previously_failed = []
|
|
||||||
previously_passed = []
|
|
||||||
for item in items:
|
|
||||||
if item.nodeid in self.lastfailed:
|
|
||||||
previously_failed.append(item)
|
|
||||||
else:
|
|
||||||
previously_passed.append(item)
|
|
||||||
self._previously_failed_count = len(previously_failed)
|
|
||||||
|
|
||||||
if not previously_failed:
|
if self.lastfailed:
|
||||||
# Running a subset of all tests with recorded failures
|
previously_failed = []
|
||||||
# only outside of it.
|
previously_passed = []
|
||||||
self._report_status = "%d known failures not in selected tests" % (
|
for item in items:
|
||||||
len(self.lastfailed),
|
if item.nodeid in self.lastfailed:
|
||||||
)
|
previously_failed.append(item)
|
||||||
else:
|
else:
|
||||||
if self.config.getoption("lf"):
|
previously_passed.append(item)
|
||||||
items[:] = previously_failed
|
self._previously_failed_count = len(previously_failed)
|
||||||
config.hook.pytest_deselected(items=previously_passed)
|
|
||||||
else: # --failedfirst
|
|
||||||
items[:] = previously_failed + previously_passed
|
|
||||||
|
|
||||||
noun = (
|
if not previously_failed:
|
||||||
"failure" if self._previously_failed_count == 1 else "failures"
|
# Running a subset of all tests with recorded failures
|
||||||
)
|
# only outside of it.
|
||||||
suffix = " first" if self.config.getoption("failedfirst") else ""
|
self._report_status = "%d known failures not in selected tests" % (
|
||||||
self._report_status = "rerun previous {count} {noun}{suffix}".format(
|
len(self.lastfailed),
|
||||||
count=self._previously_failed_count, suffix=suffix, noun=noun
|
)
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self._report_status = "no previously failed tests, "
|
if self.config.getoption("lf"):
|
||||||
if self.config.getoption("last_failed_no_failures") == "none":
|
items[:] = previously_failed
|
||||||
self._report_status += "deselecting all items."
|
config.hook.pytest_deselected(items=previously_passed)
|
||||||
config.hook.pytest_deselected(items=items)
|
else: # --failedfirst
|
||||||
items[:] = []
|
items[:] = previously_failed + previously_passed
|
||||||
else:
|
|
||||||
self._report_status += "not deselecting items."
|
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
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self._report_status = "no previously failed tests, "
|
||||||
|
if self.config.getoption("last_failed_no_failures") == "none":
|
||||||
|
self._report_status += "deselecting all items."
|
||||||
|
config.hook.pytest_deselected(items=items)
|
||||||
|
items[:] = []
|
||||||
|
else:
|
||||||
|
self._report_status += "not deselecting items."
|
||||||
|
|
||||||
def pytest_sessionfinish(self, session):
|
def pytest_sessionfinish(self, session):
|
||||||
config = self.config
|
config = self.config
|
||||||
|
|
Loading…
Reference in New Issue