File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ """Global fixtures and settings for the pytest test suite"""
2+ import sys
3+ import os
4+
5+ # Add test helper modules to search path with out making "tests" a Python package
6+ sys .path .append (os .path .join (os .path .dirname (__file__ ), "helpers" ))
Original file line number Diff line number Diff line change 1+ import logging
2+ from typing import List
3+
4+
5+ class FormattedMessageCollectorHandler (logging .Handler ):
6+ """A logging handler that stores formatted log records in its "messages" attribute."""
7+
8+ def __init__ (self , level = logging .NOTSET ) -> None :
9+ """Create a new log handler."""
10+ super ().__init__ (level = level )
11+ self .level = level
12+ self .messages : List [str ] = []
13+
14+ def emit (self , record : logging .LogRecord ) -> None :
15+ """Keep the log records in a list in addition to the log text."""
16+ self .messages .append (self .format (record ))
17+
18+ def reset (self ) -> None :
19+ """Empty the list of messages"""
20+ self .messages = []
You can’t perform that action at this time.
0 commit comments