logging: use item's store for private attributes

This makes things type-safe and properly private.
This commit is contained in:
Ran Benita
2020-05-17 14:58:04 +03:00
parent d4dfe863c9
commit ac6c02f1e2
3 changed files with 17 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
import logging
import pytest
from _pytest.logging import catch_log_handlers_key
logger = logging.getLogger(__name__)
sublogger = logging.getLogger(__name__ + ".baz")
@@ -136,4 +137,4 @@ def test_caplog_captures_for_all_stages(caplog, logging_during_setup_and_teardow
assert [x.message for x in caplog.get_records("setup")] == ["a_setup_log"]
# This reaches into private API, don't use this type of thing in real tests!
assert set(caplog._item.catch_log_handlers.keys()) == {"setup", "call"}
assert set(caplog._item._store[catch_log_handlers_key]) == {"setup", "call"}