1212import cli_ui
1313from cli_ui .tests .conftest import MessageRecorder
1414
15-
16- def assert_equal_strings (a : str , b : str ) -> bool :
17- return a .split () == b .split ()
15+ BLUE = colorama .Fore .BLUE
16+ GREEN = colorama .Fore .GREEN
17+ RED = colorama .Fore .RED
18+ RESET_ALL = colorama .Style .RESET_ALL
19+ BRIGHT = colorama .Style .BRIGHT
1820
1921
2022class SmartTTY (io .StringIO ):
@@ -59,16 +61,10 @@ def test_info_stdout_is_a_tty(smart_tty: io.StringIO) -> None:
5961 )
6062 # fmt: on
6163 expected = (
62- colorama .Fore .RED
63- + "this is red "
64- + colorama .Style .RESET_ALL
65- + colorama .Fore .GREEN
66- + "this is green"
67- + colorama .Style .RESET_ALL
68- + "\n "
64+ RED + "this is red " + RESET_ALL + GREEN + "this is green" + "\n " + RESET_ALL
6965 )
7066 actual = smart_tty .getvalue ()
71- assert_equal_strings ( actual , expected )
67+ assert actual == expected
7268
7369
7470def test_update_title (smart_tty : SmartTTY ) -> None :
@@ -78,17 +74,13 @@ def test_update_title(smart_tty: SmartTTY) -> None:
7874 fileobj = smart_tty ,
7975 update_title = True
8076 )
81- # fmt: on
8277 expected = (
83- colorama .ansi .set_title ("Something bold" )
84- + "Something "
85- + colorama .Style .BRIGHT
86- + "bold"
87- + colorama .Style .RESET_ALL
88- + "\n "
78+ "\x1b ]0;Something bold\n \x07 "
79+ f"Something { BRIGHT } bold\n { RESET_ALL } "
8980 )
81+ # fmt: on
9082 actual = smart_tty .getvalue ()
91- assert_equal_strings ( actual , expected )
83+ assert actual == expected
9284
9385
9486def test_info_stdout_is_not_a_tty (dumb_tty : DumbTTY ) -> None :
@@ -101,23 +93,16 @@ def test_info_stdout_is_not_a_tty(dumb_tty: DumbTTY) -> None:
10193 # fmt: on
10294 expected = "this is red this is green\n "
10395 actual = dumb_tty .getvalue ()
104- assert_equal_strings ( actual , expected )
96+ assert actual == expected
10597
10698
10799def test_info_characters (smart_tty : SmartTTY ) -> None :
108100 cli_ui .info (
109101 "Doing stuff" , cli_ui .ellipsis , "sucess" , cli_ui .check , fileobj = smart_tty
110102 )
111103 actual = smart_tty .getvalue ()
112- expected = (
113- "Doing stuff "
114- + colorama .Style .RESET_ALL
115- + "…"
116- + " sucess "
117- + colorama .Fore .GREEN
118- + "✓"
119- )
120- assert_equal_strings (actual , expected )
104+ expected = f"Doing stuff { RESET_ALL } { RESET_ALL } … { RESET_ALL } sucess { RESET_ALL } { GREEN } ✓ { RESET_ALL } \n { RESET_ALL } "
105+ assert actual == expected
121106
122107
123108def test_timestamp (dumb_tty : DumbTTY , toggle_timestamp : None ) -> None :
0 commit comments