Skip to content

Commit 763b6ed

Browse files
authored
gh-158536: Skip some Android logging tests on OS versions with aggressive "chatty" filtering (#158531)
Address a test suite failure when run on Android 26-30 (inclusive) due to the adb logger dropping lines with a "chatty ... Identical 3 lines" marker.
1 parent e580c88 commit 763b6ed

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎Lib/test/test_android.py‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io
2+
import platform
23
import queue
34
import re
45
import subprocess
@@ -16,6 +17,11 @@
1617
if 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)
2026
STREAM_INFO = [("stdout", "I", 1), ("stderr", "W", 2)]
2127

@@ -179,15 +185,13 @@ def write(s, lines=None, *, write_len=None):
179185
write("\u0000b", [r"\xc0\x80b"])
180186
write("a\u0000b", [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("\nx", [" "])
188191
write("\na\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\ne", ["d"])
@@ -206,7 +210,8 @@ def write(s, lines=None, *, write_len=None):
206210
write("\nx", [" ", "x"])
207211
write("\na\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\ne", ["d", "e"])

0 commit comments

Comments
 (0)