$38 GRAYBYTE WORDPRESS FILE MANAGER $68

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cloudlinux/venv/lib/python3.11/site-packages/testfixtures/

HOME
Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/testfixtures//shouldwarn.py
import warnings
from typing import Union, Type

from testfixtures import Comparison as C, compare


WarningOrType = Union[Warning, Type[Warning]]


class ShouldWarn(warnings.catch_warnings):
    """
    This context manager is used to assert that warnings are issued
    within the context it is managing.

    :param expected: This should be a sequence made up of one or more elements,
                     each of one of the following types:

                     * A warning class, indicating that the type
                       of the warnings is important but not the
                       parameters it is created with.

                     * A warning instance, indicating that a
                       warning exactly matching the one supplied
                       should have been issued.

                     If no expected warnings are passed, you will need to inspect
                     the contents of the list returned by the context manager.

    :param filters:
      If passed, these are used to create a filter such that only warnings you
      are interested in will be considered by this :class:`ShouldWarn`
      instance. The names and meanings are the same as the parameters for
      :func:`warnings.filterwarnings`.

    """

    _empty_okay = False

    def __init__(self, *expected: WarningOrType, **filters):
        super(ShouldWarn, self).__init__(record=True)
        self.expected = [C(e) for e in expected]
        self.filters = filters

    def __enter__(self):
        self.recorded = super(ShouldWarn, self).__enter__()
        warnings.filterwarnings("always", **self.filters)
        return self.recorded

    def __exit__(self, exc_type, exc_val, exc_tb):
        super(ShouldWarn, self).__exit__(exc_type, exc_val, exc_tb)
        if not self.recorded and self._empty_okay:
            return
        if not self.expected and self.recorded and not self._empty_okay:
            return
        compare(self.expected, actual=[wm.message for wm in self.recorded])


class ShouldNotWarn(ShouldWarn):
    """
    This context manager is used to assert that no warnings are issued
    within the context it is managing.
    """

    _empty_okay = True

    def __init__(self):
        super(ShouldNotWarn, self).__init__()

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
17 Dec 2025 3.08 AM
root / root
0755
__pycache__
--
14 Aug 2025 9.24 PM
root / root
0755
tests
--
14 Aug 2025 9.24 PM
root / root
0755
__init__.py
1.194 KB
17 Apr 2025 8.10 PM
root / root
0644
comparison.py
39.142 KB
17 Apr 2025 8.10 PM
root / root
0644
compat.py
0.219 KB
17 Apr 2025 8.10 PM
root / root
0644
components.py
1.306 KB
17 Apr 2025 8.10 PM
root / root
0644
datetime.py
24.423 KB
17 Apr 2025 8.10 PM
root / root
0644
django.py
2.885 KB
17 Apr 2025 8.10 PM
root / root
0644
logcapture.py
10.755 KB
17 Apr 2025 8.10 PM
root / root
0644
mock.py
1.205 KB
17 Apr 2025 8.10 PM
root / root
0644
outputcapture.py
4.688 KB
17 Apr 2025 8.10 PM
root / root
0644
popen.py
9.887 KB
17 Apr 2025 8.10 PM
root / root
0644
replace.py
12.149 KB
17 Apr 2025 8.10 PM
root / root
0644
resolve.py
2.054 KB
17 Apr 2025 8.10 PM
root / root
0644
rmtree.py
2.523 KB
17 Apr 2025 8.10 PM
root / root
0644
shouldraise.py
3.578 KB
17 Apr 2025 8.10 PM
root / root
0644
shouldwarn.py
2.213 KB
17 Apr 2025 8.10 PM
root / root
0644
sybil.py
2.279 KB
17 Apr 2025 8.10 PM
root / root
0644
tempdirectory.py
12.887 KB
17 Apr 2025 8.10 PM
root / root
0644
twisted.py
4.8 KB
17 Apr 2025 8.10 PM
root / root
0644
utils.py
2.737 KB
17 Apr 2025 8.10 PM
root / root
0644
version.txt
0.006 KB
17 Apr 2025 8.10 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF