Skip to content

Make Index Default Key #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename to avoid hook rook rule complaint
  • Loading branch information
rmorshea committed Jan 11, 2022
commit 7dd70b60c3ff0a0e104b454f8b2edd7e11759edc
10 changes: 6 additions & 4 deletions src/idom/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def assert_idom_logged(
error_pattern = re.compile(match_error)

try:
with capture_idom_logs(use_existing=clear_matched_records) as log_records:
with capture_idom_logs(yield_existing=clear_matched_records) as log_records:
yield None
except Exception:
raise
Expand Down Expand Up @@ -281,16 +281,18 @@ def _raise_log_message_error(


@contextmanager
def capture_idom_logs(use_existing: bool = False) -> Iterator[list[logging.LogRecord]]:
def capture_idom_logs(
yield_existing: bool = False,
) -> Iterator[list[logging.LogRecord]]:
"""Capture logs from IDOM

Parameters:
use_existing:
yield_existing:
If already inside an existing capture context yield the same list of logs.
This is useful if you need to mutate the list of logs to affect behavior in
the outer context.
"""
if use_existing:
if yield_existing:
for handler in reversed(ROOT_LOGGER.handlers):
if isinstance(handler, _LogRecordCaptor):
yield handler.records
Expand Down