summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMalcolm Smith <smith@chaquo.com>2024-08-16 05:00:29 (GMT)
committerGitHub <noreply@github.com>2024-08-16 05:00:29 (GMT)
commitf84cce6f2588c6437d69a30856d7c4ba00b70ae0 (patch)
treee1a99f5e59aa7588c9d548217bfd8fdd47384ccd /Lib/test
parente913d2c87f1ae4e7a4aef5ba78368ef31d060767 (diff)
downloadcpython-f84cce6f2588c6437d69a30856d7c4ba00b70ae0.zip
cpython-f84cce6f2588c6437d69a30856d7c4ba00b70ae0.tar.gz
cpython-f84cce6f2588c6437d69a30856d7c4ba00b70ae0.tar.bz2
gh-116622: Add Android test script (#121595)
Adds a script for running the test suite on Android emulator devices. Starting with a fresh install of the Android Commandline tools; the script manages installing other requirements, starting the emulator (if required), and retrieving results from that emulator.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/libregrtest/cmdline.py4
-rw-r--r--Lib/test/test_android.py13
2 files changed, 11 insertions, 6 deletions
diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
index 2ff4715..8bef04c 100644
--- a/Lib/test/libregrtest/cmdline.py
+++ b/Lib/test/libregrtest/cmdline.py
@@ -428,9 +428,7 @@ def _parse_args(args, **kwargs):
# Continuous Integration (CI): common options for fast/slow CI modes
if ns.slow_ci or ns.fast_ci:
# Similar to options:
- #
- # -j0 --randomize --fail-env-changed --fail-rerun --rerun
- # --slowest --verbose3
+ # -j0 --randomize --fail-env-changed --rerun --slowest --verbose3
if ns.use_mp is None:
ns.use_mp = 0
ns.randomize = True
diff --git a/Lib/test/test_android.py b/Lib/test/test_android.py
index 8203506..09fa21c 100644
--- a/Lib/test/test_android.py
+++ b/Lib/test/test_android.py
@@ -19,6 +19,9 @@ if sys.platform != "android":
api_level = platform.android_ver().api_level
+# (name, level, fileno)
+STREAM_INFO = [("stdout", "I", 1), ("stderr", "W", 2)]
+
# Test redirection of stdout and stderr to the Android log.
@unittest.skipIf(
@@ -94,19 +97,21 @@ class TestAndroidOutput(unittest.TestCase):
stack = ExitStack()
stack.enter_context(self.subTest(stream_name))
stream = getattr(sys, stream_name)
+ native_stream = getattr(sys, f"__{stream_name}__")
if isinstance(stream, io.StringIO):
stack.enter_context(
patch(
f"sys.{stream_name}",
TextLogStream(
- prio, f"python.{stream_name}", errors="backslashreplace"
+ prio, f"python.{stream_name}", native_stream.fileno(),
+ errors="backslashreplace"
),
)
)
return stack
def test_str(self):
- for stream_name, level in [("stdout", "I"), ("stderr", "W")]:
+ for stream_name, level, fileno in STREAM_INFO:
with self.stream_context(stream_name, level):
stream = getattr(sys, stream_name)
tag = f"python.{stream_name}"
@@ -114,6 +119,7 @@ class TestAndroidOutput(unittest.TestCase):
self.assertIs(stream.writable(), True)
self.assertIs(stream.readable(), False)
+ self.assertEqual(stream.fileno(), fileno)
self.assertEqual("UTF-8", stream.encoding)
self.assertIs(stream.line_buffering, True)
self.assertIs(stream.write_through, False)
@@ -257,13 +263,14 @@ class TestAndroidOutput(unittest.TestCase):
write("\n", [s * 51]) # 0 bytes in, 510 bytes out
def test_bytes(self):
- for stream_name, level in [("stdout", "I"), ("stderr", "W")]:
+ for stream_name, level, fileno in STREAM_INFO:
with self.stream_context(stream_name, level):
stream = getattr(sys, stream_name).buffer
tag = f"python.{stream_name}"
self.assertEqual(f"<BinaryLogStream '{tag}'>", repr(stream))
self.assertIs(stream.writable(), True)
self.assertIs(stream.readable(), False)
+ self.assertEqual(stream.fileno(), fileno)
def write(b, lines=None, *, write_len=None):
if write_len is None: