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

Method test_pickle

tests/test_output.py:300–314  ·  view source on GitHub ↗

Can be pickled and unpickled for stdout and stderr. Can't compare output because capsys et all would confuse the logic.

(self, file, proto)

Source from the content-addressed store, hash-verified

298 @pytest.mark.parametrize("file", [None, stdout.buffer, stderr.buffer])
299 @pytest.mark.parametrize("proto", range(pickle.HIGHEST_PROTOCOL + 1))
300 def test_pickle(self, file, proto):
301 """
302 Can be pickled and unpickled for stdout and stderr.
303
304 Can't compare output because capsys et all would confuse the logic.
305 """
306 pl = BytesLogger(file=file)
307
308 rv = pickle.loads(pickle.dumps(pl, proto))
309
310 rv.msg(b"hello") # doesn't raise an error
311
312 assert pl._file is rv._file
313 assert pl._lock is rv._lock
314 assert rv.name is None
315
316 @pytest.mark.parametrize("proto", range(pickle.HIGHEST_PROTOCOL + 1))
317 def test_pickle_preserves_name(self, proto):

Callers

nothing calls this directly

Calls 2

BytesLoggerClass · 0.90
msgMethod · 0.45

Tested by

no test coverage detected