MCPcopy Create free account
hub / github.com/hynek/structlog / test_errWithFailure

Method test_errWithFailure

tests/test_twisted.py:78–98  ·  view source on GitHub ↗

Failures are correctly injected into the log entries.

(self)

Source from the content-addressed store, hash-verified

76 assert "foo=42 event='event'" == bl.err("event", foo=42)
77
78 def test_errWithFailure(self):
79 """
80 Failures are correctly injected into the log entries.
81 """
82 bl = build_bl(
83 processors=[EventAdapter(dictRenderer=KeyValueRenderer())]
84 )
85 try:
86 raise ValueError
87 except ValueError:
88 # Use str() for comparison to avoid tricky
89 # deep-compares of Failures.
90 assert str(
91 (
92 (),
93 {
94 "_stuff": Failure(ValueError()),
95 "_why": "foo=42 event='event'",
96 },
97 )
98 ) == str(bl.err("event", foo=42))
99
100
101class TestExtractStuffAndWhy:

Callers

nothing calls this directly

Calls 4

EventAdapterClass · 0.90
KeyValueRendererClass · 0.90
build_blFunction · 0.70
errMethod · 0.45

Tested by

no test coverage detected