MCPcopy Index your code
hub / github.com/python/cpython / check_tracebacks

Function check_tracebacks

Lib/test/test_sqlite3/util.py:45–63  ·  view source on GitHub ↗

Convenience context manager for testing callback tracebacks.

(self, cm, exc, exc_regex, msg_regex, obj_name)

Source from the content-addressed store, hash-verified

43
44@contextlib.contextmanager
45def check_tracebacks(self, cm, exc, exc_regex, msg_regex, obj_name):
46 """Convenience context manager for testing callback tracebacks."""
47 sqlite3.enable_callback_tracebacks(True)
48 try:
49 buf = io.StringIO()
50 with contextlib.redirect_stderr(buf):
51 yield
52
53 self.assertEqual(cm.unraisable.exc_type, exc)
54 if exc_regex:
55 msg = str(cm.unraisable.exc_value)
56 self.assertIsNotNone(exc_regex.search(msg), (exc_regex, msg))
57 if msg_regex:
58 msg = cm.unraisable.err_msg
59 self.assertIsNotNone(msg_regex.search(msg), (msg_regex, msg))
60 if obj_name:
61 self.assertEqual(cm.unraisable.object.__name__, obj_name)
62 finally:
63 sqlite3.enable_callback_tracebacks(False)
64
65
66class MemoryDatabaseMixin:

Callers 1

wrapperFunction · 0.85

Calls 4

strFunction · 0.85
assertIsNotNoneMethod · 0.80
assertEqualMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…