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.
10 import multiprocessing
27 @pytest.fixture(scope=
"session", autouse=
True)
29 if sys.platform !=
"linux":
38 multiprocessing.set_start_method(
"forkserver")
41 _long_marker = re.compile(
r"([0-9])L")
42 _hexadecimal = re.compile(
r"0x[0-9a-fA-F]+")
49 """For triple-quote strings"""
50 return textwrap.dedent(s.lstrip(
"\n").rstrip())
54 """For output which does not require specific line order"""
59 """Explanation for a failed assert -- the a and b arguments are List[str]"""
60 return [
"--- actual / +++ expected"] + [
61 line.strip(
"\n")
for line
in difflib.ndiff(a, b)
66 """Basic output post-processing and comparison"""
79 for line
in self.
string.strip().splitlines()
80 if not line.startswith(
"###")
90 """Custom comparison for output without strict line ordering"""
108 self.
capfd.readouterr()
126 return item
in self.
out
139 """Extended `capsys` with context manager and custom equality operators"""
164 s = s.replace(
"pybind11_tests.",
"m.")
165 return _long_marker.sub(
r"\1", s)
175 """Sanitize docstrings and add custom failure explanation"""
182 return _hexadecimal.sub(
"0", s)
187 """Sanitize messages and add custom failure explanation"""
192 """Hook to insert custom failure explanation"""
193 if hasattr(left,
"explanation"):
194 return left.explanation
199 """Run the garbage collector twice (needed when running
200 reference counting tests with PyPy)"""
206 pytest.suppress = contextlib.suppress
207 pytest.gc_collect = gc_collect
213 pybind11_tests.compiler_info
is not None
214 ),
"Please update pybind11_tests.cpp if this assert fails."
217 f
" {pybind11_tests.compiler_info}"
218 f
" {pybind11_tests.cpp_std}"
219 f
" {pybind11_tests.PYBIND11_INTERNALS_ID}"
220 f
" PYBIND11_SIMPLE_GIL_MANAGEMENT={pybind11_tests.PYBIND11_SIMPLE_GIL_MANAGEMENT}"
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 Mon Jul 1 2024 03:00:58