SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > site-packages > _pytest > >


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/cloudlinux/venv/lib64/python3.11/site-packages/_pytest//

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
_code Directory - -
_io Directory - -
_py Directory - -
assertion Directory - -
config Directory - -
mark Directory - -
__init__.py File 356 bytes April 17 2025 13:10:59.
_argcomplete.py File 3794 bytes April 17 2025 13:10:59.
_version.py File 160 bytes April 17 2025 13:10:59.
cacheprovider.py File 21392 bytes April 17 2025 13:10:59.
capture.py File 34737 bytes April 17 2025 13:10:59.
compat.py File 13200 bytes April 17 2025 13:10:59.
debugging.py File 13498 bytes April 17 2025 13:10:59.
deprecated.py File 5487 bytes April 17 2025 13:10:59.
doctest.py File 25961 bytes April 17 2025 13:10:59.
faulthandler.py File 3114 bytes April 17 2025 13:10:59.
fixtures.py File 67085 bytes April 17 2025 13:10:59.
freeze_support.py File 1339 bytes April 17 2025 13:10:59.
helpconfig.py File 8538 bytes April 17 2025 13:10:59.
hookspec.py File 32558 bytes April 17 2025 13:10:59.
junitxml.py File 25716 bytes April 17 2025 13:10:59.
legacypath.py File 16929 bytes April 17 2025 13:10:59.
logging.py File 34031 bytes April 17 2025 13:10:59.
main.py File 32491 bytes April 17 2025 13:10:59.
monkeypatch.py File 14857 bytes April 17 2025 13:10:59.
nodes.py File 26559 bytes April 17 2025 13:10:59.
nose.py File 1688 bytes April 17 2025 13:10:59.
outcomes.py File 10256 bytes April 17 2025 13:10:59.
pastebin.py File 3949 bytes April 17 2025 13:10:59.
pathlib.py File 25824 bytes April 17 2025 13:10:59.
py.typed File 0 bytes April 17 2025 13:10:59.
pytester.py File 61971 bytes April 17 2025 13:10:59.
pytester_assertions.py File 2327 bytes April 17 2025 13:10:59.
python.py File 71155 bytes April 17 2025 13:10:59.
python_api.py File 38400 bytes April 17 2025 13:10:59.
python_path.py File 709 bytes April 17 2025 13:10:59.
recwarn.py File 10930 bytes April 17 2025 13:10:59.
reports.py File 20840 bytes April 17 2025 13:10:59.
runner.py File 18447 bytes April 17 2025 13:10:59.
scope.py File 2882 bytes April 17 2025 13:10:59.
setuponly.py File 3261 bytes April 17 2025 13:10:59.
setupplan.py File 1214 bytes April 17 2025 13:10:59.
skipping.py File 10200 bytes April 17 2025 13:10:59.
stash.py File 3055 bytes April 17 2025 13:10:59.
stepwise.py File 4714 bytes April 17 2025 13:10:59.
terminal.py File 53509 bytes April 17 2025 13:10:59.
threadexception.py File 2915 bytes April 17 2025 13:10:59.
timing.py File 375 bytes April 17 2025 13:10:59.
tmpdir.py File 11708 bytes April 17 2025 13:10:59.
unittest.py File 14809 bytes April 17 2025 13:10:59.
unraisableexception.py File 3191 bytes April 17 2025 13:10:59.
warning_types.py File 4474 bytes April 17 2025 13:10:59.
warnings.py File 5070 bytes April 17 2025 13:10:59.

Reading File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/_pytest///stepwise.py

from typing import List
from typing import Optional
from typing import TYPE_CHECKING

import pytest
from _pytest import nodes
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from _pytest.main import Session
from _pytest.reports import TestReport

if TYPE_CHECKING:
    from _pytest.cacheprovider import Cache

STEPWISE_CACHE_DIR = "cache/stepwise"


def pytest_addoption(parser: Parser) -> None:
    group = parser.getgroup("general")
    group.addoption(
        "--sw",
        "--stepwise",
        action="store_true",
        default=False,
        dest="stepwise",
        help="Exit on test failure and continue from last failing test next time",
    )
    group.addoption(
        "--sw-skip",
        "--stepwise-skip",
        action="store_true",
        default=False,
        dest="stepwise_skip",
        help="Ignore the first failing test but stop on the next failing test. "
        "Implicitly enables --stepwise.",
    )


@pytest.hookimpl
def pytest_configure(config: Config) -> None:
    if config.option.stepwise_skip:
        # allow --stepwise-skip to work on it's own merits.
        config.option.stepwise = True
    if config.getoption("stepwise"):
        config.pluginmanager.register(StepwisePlugin(config), "stepwiseplugin")


def pytest_sessionfinish(session: Session) -> None:
    if not session.config.getoption("stepwise"):
        assert session.config.cache is not None
        if hasattr(session.config, "workerinput"):
            # Do not update cache if this process is a xdist worker to prevent
            # race conditions (#10641).
            return
        # Clear the list of failing tests if the plugin is not active.
        session.config.cache.set(STEPWISE_CACHE_DIR, [])


class StepwisePlugin:
    def __init__(self, config: Config) -> None:
        self.config = config
        self.session: Optional[Session] = None
        self.report_status = ""
        assert config.cache is not None
        self.cache: Cache = config.cache
        self.lastfailed: Optional[str] = self.cache.get(STEPWISE_CACHE_DIR, None)
        self.skip: bool = config.getoption("stepwise_skip")

    def pytest_sessionstart(self, session: Session) -> None:
        self.session = session

    def pytest_collection_modifyitems(
        self, config: Config, items: List[nodes.Item]
    ) -> None:
        if not self.lastfailed:
            self.report_status = "no previously failed tests, not skipping."
            return

        # check all item nodes until we find a match on last failed
        failed_index = None
        for index, item in enumerate(items):
            if item.nodeid == self.lastfailed:
                failed_index = index
                break

        # If the previously failed test was not found among the test items,
        # do not skip any tests.
        if failed_index is None:
            self.report_status = "previously failed test not found, not skipping."
        else:
            self.report_status = f"skipping {failed_index} already passed items."
            deselected = items[:failed_index]
            del items[:failed_index]
            config.hook.pytest_deselected(items=deselected)

    def pytest_runtest_logreport(self, report: TestReport) -> None:
        if report.failed:
            if self.skip:
                # Remove test from the failed ones (if it exists) and unset the skip option
                # to make sure the following tests will not be skipped.
                if report.nodeid == self.lastfailed:
                    self.lastfailed = None

                self.skip = False
            else:
                # Mark test as the last failing and interrupt the test session.
                self.lastfailed = report.nodeid
                assert self.session is not None
                self.session.shouldstop = (
                    "Test failed, continuing from this test next run."
                )

        else:
            # If the test was actually run and did pass.
            if report.when == "call":
                # Remove test from the failed ones, if exists.
                if report.nodeid == self.lastfailed:
                    self.lastfailed = None

    def pytest_report_collectionfinish(self) -> Optional[str]:
        if self.config.getoption("verbose") >= 0 and self.report_status:
            return f"stepwise: {self.report_status}"
        return None

    def pytest_sessionfinish(self) -> None:
        if hasattr(self.config, "workerinput"):
            # Do not update cache if this process is a xdist worker to prevent
            # race conditions (#10641).
            return
        self.cache.set(STEPWISE_CACHE_DIR, self.lastfailed)

SILENT KILLER Tool