Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > > site-packages > testfixtures
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 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
__pycache__ | Directory | - | - | |
tests | Directory | - | - | |
__init__.py | File | 1223 bytes | April 17 2025 13:10:58. | |
comparison.py | File | 40081 bytes | April 17 2025 13:10:58. | |
compat.py | File | 224 bytes | April 17 2025 13:10:58. | |
components.py | File | 1337 bytes | April 17 2025 13:10:58. | |
datetime.py | File | 25009 bytes | April 17 2025 13:10:58. | |
django.py | File | 2954 bytes | April 17 2025 13:10:58. | |
logcapture.py | File | 11013 bytes | April 17 2025 13:10:58. | |
mock.py | File | 1234 bytes | April 17 2025 13:10:58. | |
outputcapture.py | File | 4801 bytes | April 17 2025 13:10:58. | |
popen.py | File | 10124 bytes | April 17 2025 13:10:58. | |
replace.py | File | 12441 bytes | April 17 2025 13:10:58. | |
resolve.py | File | 2103 bytes | April 17 2025 13:10:58. | |
rmtree.py | File | 2584 bytes | April 17 2025 13:10:58. | |
shouldraise.py | File | 3664 bytes | April 17 2025 13:10:58. | |
shouldwarn.py | File | 2266 bytes | April 17 2025 13:10:58. | |
sybil.py | File | 2334 bytes | April 17 2025 13:10:58. | |
tempdirectory.py | File | 13196 bytes | April 17 2025 13:10:58. | |
twisted.py | File | 4915 bytes | April 17 2025 13:10:58. | |
utils.py | File | 2803 bytes | April 17 2025 13:10:58. | |
version.txt | File | 6 bytes | April 17 2025 13:10:58. |
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__()
SILENT KILLER Tool