def pytest_collection_modifyitems(self, session, config, items):
    if self.active:
        if self.lastfailed:
            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):
                return
            if self.config.getoption('lf'):
                items[:] = previously_failed
                config.hook.pytest_deselected(items=previously_passed)
            else:
                items[:] = (previously_failed + previously_passed)
        elif (self._no_failures_behavior == 'none'):
            config.hook.pytest_deselected(items=items)
            items[:] = []
def pytest_collection_modifyitems(self, session, config, items):
    if self.active:
        if self.lastfailed:
            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):
                return
            if self.config.getoption('lf'):
                items[:] = previously_failed
                config.hook.pytest_deselected(items=previously_passed)
            else:
                items[:] = (previously_failed + previously_passed)
        elif (self._no_failures_behavior == 'none'):
            config.hook.pytest_deselected(items=items)
            items[:] = []