def test_json_formatter_easy_extra_types(json_formatter): record = LogRecord( name='test', level=INFO, pathname='/test.py', lineno=1337, msg="This is a test", args=[], exc_info=None ) record.extra_one = 'String Test' record.extra_two = 1092384901283490120984 record.extra_three = ['list test'] actual = json.loads(json_formatter.format(record)) assert_contains(actual, { 'extra_one': 'String Test', 'extra_two': 1092384901283490120984, 'extra_three': ['list test'], })
def test_json_formatter_non_easy_extra_types(json_formatter): record = LogRecord( name='test', level=INFO, pathname='/test.py', lineno=1337, msg="This is a test", args=[], exc_info=None ) class Example(object): def __repr__(self): return 'Example Repr in action!' record.extra_one = Example() actual = json.loads(json_formatter.format(record)) assert_contains(actual, { 'extra_one': 'Example Repr in action!', })