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
@@ -174,15 +180,13 @@ def write(s, lines=None, *, write_len=None):
174180 write ("\u0000 b" , [r"\xc0\x80b" ])
175181 write ("a\u0000 b" , [r"a\xc0\x80b" ])
176182
177- # Multi-line messages. Avoid identical consecutive lines, as
178- # they may activate "chatty" filtering and break the tests.
179- #
180- # Additional spaces will appear in the output where necessary to
181- # protect leading newlines.
183+ # Multi-line messages. Additional spaces will appear in the output where
184+ # necessary to protect leading newlines.
182185 write ("\n x" , [" " ])
183186 write ("\n a\n " , ["x" , "a" ])
184187 write ("\n " , [" " ])
185- write ("\n \n " , [" " , " " ])
188+ if not chatty_issue :
189+ write ("\n \n " , [" " , " " ])
186190 write ("b\n " , ["b" ])
187191 write ("c\n \n " , ["c" , " " ])
188192 write ("d\n e" , ["d" ])
@@ -201,7 +205,8 @@ def write(s, lines=None, *, write_len=None):
201205 write ("\n x" , [" " , "x" ])
202206 write ("\n a\n " , [" " , "a" ])
203207 write ("\n " , [" " ])
204- write ("\n \n " , [" " , " " ])
208+ if not chatty_issue :
209+ write ("\n \n " , [" " , " " ])
205210 write ("b\n " , ["b" ])
206211 write ("c\n \n " , ["c" , " " ])
207212 write ("d\n e" , ["d" , "e" ])
0 commit comments