Go to the documentation of this file. 1 """pytest configuration
3 Extends output capture as needed by pybind11: ignore constructors, optional unordered lines.
4 Adds docstring and exceptions message sanitizers.
7 from __future__
import annotations
12 import multiprocessing
29 @pytest.fixture(scope=
"session", autouse=
True)
31 if sys.platform !=
"linux":
40 multiprocessing.set_start_method(
"forkserver")
43 _long_marker = re.compile(
r"([0-9])L")
44 _hexadecimal = re.compile(
r"0x[0-9a-fA-F]+")
51 """For triple-quote strings"""
52 return textwrap.dedent(s.lstrip(
"\n").rstrip())
56 """For output which does not require specific line order"""
61 """Explanation for a failed assert -- the a and b arguments are List[str]"""
62 return [
"--- actual / +++ expected"] + [
63 line.strip(
"\n")
for line
in difflib.ndiff(a, b)
68 """Basic output post-processing and comparison"""
81 for line
in self.
string.strip().splitlines()
82 if not line.startswith(
"###")
92 """Custom comparison for output without strict line ordering"""
110 self.
capfd.readouterr()
128 return item
in self.
out
141 """Extended `capsys` with context manager and custom equality operators"""
166 s = s.replace(
"pybind11_tests.",
"m.")
167 return _long_marker.sub(
r"\1", s)
177 """Sanitize docstrings and add custom failure explanation"""
184 return _hexadecimal.sub(
"0", s)
189 """Sanitize messages and add custom failure explanation"""
194 """Hook to insert custom failure explanation"""
195 if hasattr(left,
"explanation"):
196 return left.explanation
201 """Run the garbage collector twice (needed when running
202 reference counting tests with PyPy)"""
208 pytest.suppress = contextlib.suppress
209 pytest.gc_collect = gc_collect
215 pybind11_tests.compiler_info
is not None
216 ),
"Please update pybind11_tests.cpp if this assert fails."
219 f
" {pybind11_tests.compiler_info}"
220 f
" {pybind11_tests.cpp_std}"
221 f
" {pybind11_tests.PYBIND11_INTERNALS_ID}"
222 f
" PYBIND11_SIMPLE_GIL_MANAGEMENT={pybind11_tests.PYBIND11_SIMPLE_GIL_MANAGEMENT}"
223 f
" PYBIND11_NUMPY_1_ONLY={pybind11_tests.PYBIND11_NUMPY_1_ONLY}"
def __init__(self, sanitizer)
def __contains__(self, item)
bool hasattr(handle obj, handle name)
def __call__(self, thing)
def _sanitize_message(thing)
def _make_explanation(a, b)
def __exit__(self, *args)
def use_multiprocessing_forkserver_on_linux()
def pytest_report_header(config)
def _sanitize_docstring(thing)
def pytest_assertrepr_compare(op, left, right)
def __init__(self, string)
def __init__(self, capfd)
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:01