12
12
13
13
class _Capture :
14
14
"Emulate an stdout object."
15
- encoding = "utf-8"
16
15
17
16
def __init__ (self ):
18
17
self ._data = []
@@ -22,7 +21,7 @@ def write(self, data):
22
21
23
22
@property
24
23
def data (self ):
25
- return b "" .join (self ._data )
24
+ return "" .join (self ._data )
26
25
27
26
def flush (self ):
28
27
pass
@@ -40,15 +39,15 @@ def fileno(self):
40
39
def test_print_formatted_text ():
41
40
f = _Capture ()
42
41
pt_print ([("" , "hello" ), ("" , "world" )], file = f )
43
- assert b "hello" in f .data
44
- assert b "world" in f .data
42
+ assert "hello" in f .data
43
+ assert "world" in f .data
45
44
46
45
47
46
@pytest .mark .skipif (is_windows (), reason = "Doesn't run on Windows yet." )
48
47
def test_print_formatted_text_backslash_r ():
49
48
f = _Capture ()
50
49
pt_print ("hello\r \n " , file = f )
51
- assert b "hello" in f .data
50
+ assert "hello" in f .data
52
51
53
52
54
53
@pytest .mark .skipif (is_windows (), reason = "Doesn't run on Windows yet." )
@@ -70,8 +69,8 @@ def test_formatted_text_with_style():
70
69
# NOTE: We pass the default (8bit) color depth, so that the unit tests
71
70
# don't start failing when environment variables change.
72
71
pt_print (tokens , style = style , file = f , color_depth = ColorDepth .DEFAULT )
73
- assert b "\x1b [0;38;5;197mHello" in f .data
74
- assert b "\x1b [0;38;5;83;3mworld" in f .data
72
+ assert "\x1b [0;38;5;197mHello" in f .data
73
+ assert "\x1b [0;38;5;83;3mworld" in f .data
75
74
76
75
77
76
@pytest .mark .skipif (is_windows (), reason = "Doesn't run on Windows yet." )
@@ -87,5 +86,5 @@ def test_html_with_style():
87
86
88
87
assert (
89
88
f .data
90
- == b "\x1b [0m\x1b [?7h\x1b [0;32mhello\x1b [0m \x1b [0;1mworld\x1b [0m\r \n \x1b [0m"
89
+ == "\x1b [0m\x1b [?7h\x1b [0;32mhello\x1b [0m \x1b [0;1mworld\x1b [0m\r \n \x1b [0m"
91
90
)
0 commit comments