11import io
2+ import platform
23import queue
34import re
45import subprocess
1617if sys .platform != "android" :
1718 raise unittest .SkipTest ("Android-specific" )
1819
20+ # Some API levels filter out consecutive identical lines and replace them with a
21+ # "chatty" marker.
22+ api_level = platform .android_ver ().api_level
23+ chatty_issue = (26 <= api_level <= 30 )
24+
1925# (name, level, fileno)
2026STREAM_INFO = [("stdout" , "I" , 1 ), ("stderr" , "W" , 2 )]
2127
@@ -179,15 +185,13 @@ def write(s, lines=None, *, write_len=None):
179185 write ("\u0000 b" , [r"\xc0\x80b" ])
180186 write ("a\u0000 b" , [r"a\xc0\x80b" ])
181187
182- # Multi-line messages. Avoid identical consecutive lines, as
183- # they may activate "chatty" filtering and break the tests.
184- #
185- # Additional spaces will appear in the output where necessary to
186- # protect leading newlines.
188+ # Multi-line messages. Additional spaces will appear in the output where
189+ # necessary to protect leading newlines.
187190 write ("\n x" , [" " ])
188191 write ("\n a\n " , ["x" , "a" ])
189192 write ("\n " , [" " ])
190- write ("\n \n " , [" " , " " ])
193+ if not chatty_issue :
194+ write ("\n \n " , [" " , " " ])
191195 write ("b\n " , ["b" ])
192196 write ("c\n \n " , ["c" , " " ])
193197 write ("d\n e" , ["d" ])
@@ -206,7 +210,8 @@ def write(s, lines=None, *, write_len=None):
206210 write ("\n x" , [" " , "x" ])
207211 write ("\n a\n " , [" " , "a" ])
208212 write ("\n " , [" " ])
209- write ("\n \n " , [" " , " " ])
213+ if not chatty_issue :
214+ write ("\n \n " , [" " , " " ])
210215 write ("b\n " , ["b" ])
211216 write ("c\n \n " , ["c" , " " ])
212217 write ("d\n e" , ["d" , "e" ])
0 commit comments