GRAYBYTE WORDPRESS FILE MANAGER1404

Server IP : 198.54.121.189 / Your IP : 216.73.216.224
System : Linux premium69.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
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/cloudlinux/venv/lib/python3.11/site-packages/pytest_check/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/pytest_check//context_manager.py
from __future__ import annotations
import warnings
import traceback
from types import TracebackType
from typing import Callable, Type

from . import check_log
from .check_log import log_failure

_stop_on_fail = False

# This class has grown into much more than just a context manager.
# it's really the interface into the system.
# TODO: maybe rename it
# TODO: maybe pull in extra functionality here instead of in plugin.py


class CheckContextManager:
    def __init__(self) -> None:
        self.msg: object = None

    def __enter__(self) -> "CheckContextManager":
        return self

    def __exit__(
        self,
        exc_type: Type[BaseException] | None,
        exc_val: BaseException | None,
        exc_tb: TracebackType | None,
    ) -> bool | None:
        __tracebackhide__ = True
        if exc_type is not None and issubclass(exc_type, AssertionError):
            if _stop_on_fail:
                self.msg = None
                return None
            else:
                fmt_tb = traceback.format_exception(exc_type, exc_val, exc_tb)
                if self.msg is not None:
                    log_failure(f"{exc_val}, {self.msg}", tb=fmt_tb)
                else:
                    log_failure(exc_val, tb=fmt_tb)
                self.msg = None
                return True
        self.msg = None
        return None

    def __call__(self, msg: object = None) -> "CheckContextManager":
        self.msg = msg
        return self

    def set_no_tb(self) -> None:
        warnings.warn(
            "set_no_tb() is deprecated; use set_max_tb(0)", DeprecationWarning
            )
        check_log._max_tb = 0

    def set_max_fail(self, x: int) -> None:
        check_log._max_fail = x

    def set_max_report(self, x: int) -> None:
        check_log._max_report = x

    def set_max_tb(self, x: int) -> None:
        check_log._max_tb = x

    def call_on_fail(self, func: Callable[[str], None]) -> None:
        """Experimental feature - may change with any release"""
        check_log._fail_function = func


check = CheckContextManager()

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
June 25 2025 08:31:36
root / root
0755
__pycache__
--
May 15 2025 08:30:34
root / root
0755
__init__.py
1.401 KB
April 17 2025 13:10:59
root / root
0644
check_functions.py
7.382 KB
April 17 2025 13:10:59
root / root
0644
check_log.py
2.033 KB
April 17 2025 13:10:59
root / root
0644
check_raises.py
4.269 KB
April 17 2025 13:10:59
root / root
0644
context_manager.py
2.027 KB
April 17 2025 13:10:59
root / root
0644
plugin.py
5.01 KB
April 17 2025 13:10:59
root / root
0644
pseudo_traceback.py
3.885 KB
April 17 2025 13:10:59
root / root
0644
py.typed
0 KB
April 17 2025 13:10:59
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF