Scarab  v2.9.0
Project 8 C++ Utility Library
Classes | Functions | Variables
conftest Namespace Reference

Classes

class  Capture
 
class  Output
 
class  SanitizedString
 
class  Unordered
 

Functions

def _strip_and_dedent (s)
 
def _split_and_sort (s)
 
def _make_explanation (a, b)
 
def capture (capsys)
 
def _sanitize_general (s)
 
def _sanitize_docstring (thing)
 
def doc ()
 
def _sanitize_message (thing)
 
def msg ()
 
def pytest_assertrepr_compare (op, left, right)
 
def suppress (exception)
 
def gc_collect ()
 
def pytest_configure ()
 
def _test_import_pybind11 ()
 

Variables

 _unicode_marker = re.compile(r'u(\'[^\']*\')')
 
 _long_marker = re.compile(r'([0-9])L')
 
 _hexadecimal = re.compile(r'0x[0-9a-fA-F]+')
 
list collect_ignore = []
 

Detailed Description

pytest configuration

Extends output capture as needed by pybind11: ignore constructors, optional unordered lines.
Adds docstring and exceptions message sanitizers: ignore Python 2 vs 3 differences.

Function Documentation

◆ _make_explanation()

def conftest._make_explanation (   a,
  b 
)
private
Explanation for a failed assert -- the a and b arguments are List[str]

Definition at line 36 of file conftest.py.

◆ _sanitize_docstring()

def conftest._sanitize_docstring (   thing)
private

Definition at line 145 of file conftest.py.

◆ _sanitize_general()

def conftest._sanitize_general (   s)
private

Definition at line 136 of file conftest.py.

◆ _sanitize_message()

def conftest._sanitize_message (   thing)
private

Definition at line 157 of file conftest.py.

◆ _split_and_sort()

def conftest._split_and_sort (   s)
private
For output which does not require specific line order

Definition at line 31 of file conftest.py.

◆ _strip_and_dedent()

def conftest._strip_and_dedent (   s)
private
For triple-quote strings

Definition at line 26 of file conftest.py.

◆ _test_import_pybind11()

def conftest._test_import_pybind11 ( )
private
Early diagnostic for test module initialization errors

When there is an error during initialization, the first import will report the
real error while all subsequent imports will report nonsense. This import test
is done early (in the pytest configuration file, before any tests) in order to
avoid the noise of having all tests fail with identical error messages.

Any possible exception is caught here and reported manually *without* the stack
trace. This further reduces noise since the trace would only show pytest internals
which are not useful for debugging pybind11 module issues.

Definition at line 223 of file conftest.py.

◆ capture()

def conftest.capture (   capsys)
Extended `capsys` with context manager and custom equality operators

Definition at line 111 of file conftest.py.

◆ doc()

def conftest.doc ( )
Sanitize docstrings and add custom failure explanation

Definition at line 152 of file conftest.py.

◆ gc_collect()

def conftest.gc_collect ( )
Run the garbage collector twice (needed when running
reference counting tests with PyPy) 

Definition at line 186 of file conftest.py.

◆ msg()

def conftest.msg ( )
Sanitize messages and add custom failure explanation

Definition at line 165 of file conftest.py.

◆ pytest_assertrepr_compare()

def conftest.pytest_assertrepr_compare (   op,
  left,
  right 
)
Hook to insert custom failure explanation

Definition at line 171 of file conftest.py.

◆ pytest_configure()

def conftest.pytest_configure ( )
Add import suppression and test requirements to `pytest` namespace

Definition at line 193 of file conftest.py.

◆ suppress()

def conftest.suppress (   exception)
Suppress the desired exception

Definition at line 178 of file conftest.py.

Variable Documentation

◆ _hexadecimal

_hexadecimal = re.compile(r'0x[0-9a-fA-F]+')
private

Definition at line 18 of file conftest.py.

◆ _long_marker

_long_marker = re.compile(r'([0-9])L')
private

Definition at line 17 of file conftest.py.

◆ _unicode_marker

_unicode_marker = re.compile(r'u(\'[^\']*\')')
private

Definition at line 16 of file conftest.py.

◆ collect_ignore

list collect_ignore = []

Definition at line 21 of file conftest.py.