@@ -22,7 +22,10 @@ def test_error_formatting() -> None:
2222 record = create_record ("test" , logging .ERROR , "Error message" )
2323
2424 result = formatter .format (record )
25- expected = f"{ ANSI .FOREGROUND_RED } { ANSI .BOLD } [ERROR] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } Error message"
25+ expected = (
26+ f"{ ANSI .FOREGROUND_RED .value } { ANSI .BOLD .value } "
27+ + f"[ERROR] test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } Error message"
28+ )
2629 assert result == expected
2730
2831
@@ -32,7 +35,8 @@ def test_warning_formatting() -> None:
3235
3336 result = formatter .format (record )
3437 expected = (
35- f"{ ANSI .FOREGROUND_YELLOW } { ANSI .BOLD } [WARNING] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } Warning message"
38+ f"{ ANSI .FOREGROUND_YELLOW .value } { ANSI .BOLD .value } [WARNING] "
39+ + f"test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } Warning message"
3640 )
3741 assert result == expected
3842
@@ -42,7 +46,10 @@ def test_info_formatting() -> None:
4246 record = create_record ("test" , logging .INFO , "Info message" )
4347
4448 result = formatter .format (record )
45- expected = f"{ ANSI .FOREGROUND_CYAN } { ANSI .BOLD } [INFO] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } Info message"
49+ expected = (
50+ f"{ ANSI .FOREGROUND_CYAN .value } { ANSI .BOLD .value } [INFO] "
51+ + f"test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } Info message"
52+ )
4653 assert result == expected
4754
4855
@@ -51,7 +58,10 @@ def test_debug_formatting() -> None:
5158 record = create_record ("test" , logging .DEBUG , "Debug message" )
5259
5360 result = formatter .format (record )
54- expected = f"{ ANSI .FOREGROUND_MAGENTA } { ANSI .BOLD } [DEBUG] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } Debug message"
61+ expected = (
62+ f"{ ANSI .FOREGROUND_MAGENTA .value } { ANSI .BOLD .value } "
63+ + f"[DEBUG] test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } Debug message"
64+ )
5565 assert result == expected
5666
5767
@@ -63,7 +73,10 @@ def test_dict_message_formatting() -> None:
6373 result = formatter .format (record )
6474 result_lines = result .split ("\n " )
6575
66- prefix = f"{ ANSI .FOREGROUND_CYAN } { ANSI .BOLD } [INFO] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } "
76+ prefix = (
77+ f"{ ANSI .FOREGROUND_CYAN .value } { ANSI .BOLD .value } "
78+ + f"[INFO] test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } "
79+ )
6780 assert result_lines [0 ].startswith (prefix )
6881 assert '"key": "value"' in result
6982 assert '"nested": {' in result
@@ -78,7 +91,9 @@ def test_list_message_formatting() -> None:
7891 result = formatter .format (record )
7992 result_lines = result .split ("\n " )
8093
81- prefix = f"{ ANSI .FOREGROUND_CYAN } { ANSI .BOLD } [INFO] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } "
94+ prefix = (
95+ f"{ ANSI .FOREGROUND_CYAN .value } { ANSI .BOLD .value } [INFO] test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } "
96+ )
8297 assert result_lines [0 ].startswith (prefix )
8398 assert '"item1"' in result
8499 assert '"item2"' in result
@@ -92,9 +107,12 @@ def test_multiline_message_formatting() -> None:
92107
93108 result = formatter .format (record )
94109 expected_lines = [
95- f"{ ANSI .FOREGROUND_CYAN } { ANSI .BOLD } [INFO] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } Line 1" ,
96- f"{ ANSI .FOREGROUND_CYAN } { ANSI .BOLD } [INFO] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } Line 2" ,
97- f"{ ANSI .FOREGROUND_CYAN } { ANSI .BOLD } [INFO] test{ ANSI .FOREGROUND_RESET } { ANSI .BOLD_RESET } Line 3" ,
110+ f"{ ANSI .FOREGROUND_CYAN .value } { ANSI .BOLD .value } "
111+ + f"[INFO] test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } Line 1" ,
112+ f"{ ANSI .FOREGROUND_CYAN .value } { ANSI .BOLD .value } "
113+ + f"[INFO] test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } Line 2" ,
114+ f"{ ANSI .FOREGROUND_CYAN .value } { ANSI .BOLD .value } "
115+ + f"[INFO] test{ ANSI .FOREGROUND_RESET .value } { ANSI .BOLD_RESET .value } Line 3" ,
98116 ]
99117 expected = "\n " .join (expected_lines )
100118 assert result == expected
0 commit comments