Skip to content

Commit 5903631

Browse files
[3.12] gh-125301: Backport some test support helpers (is_apple_mobile, is_apple) (GH-125311)
(cherry picked from commit 391659b)
1 parent 7c48c63 commit 5903631

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

Lib/test/support/__init__.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"requires_limited_api", "requires_specialization",
4444
# sys
4545
"MS_WINDOWS", "is_jython", "is_android", "is_emscripten", "is_wasi",
46-
"check_impl_detail", "unix_shell", "setswitchinterval",
46+
"is_apple_mobile", "check_impl_detail", "unix_shell", "setswitchinterval",
4747
# os
4848
"get_pagesize",
4949
# network
@@ -531,7 +531,7 @@ def requires_legacy_unicode_capi():
531531

532532
is_android = hasattr(sys, 'getandroidapilevel')
533533

534-
if sys.platform not in ('win32', 'vxworks'):
534+
if sys.platform not in {"win32", "vxworks", "ios", "tvos", "watchos"}:
535535
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
536536
else:
537537
unix_shell = None
@@ -541,19 +541,35 @@ def requires_legacy_unicode_capi():
541541
is_emscripten = sys.platform == "emscripten"
542542
is_wasi = sys.platform == "wasi"
543543

544-
has_fork_support = hasattr(os, "fork") and not is_emscripten and not is_wasi
544+
# Apple mobile platforms (iOS/tvOS/watchOS) are POSIX-like but do not
545+
# have subprocess or fork support.
546+
is_apple_mobile = sys.platform in {"ios", "tvos", "watchos"}
547+
is_apple = is_apple_mobile or sys.platform == "darwin"
548+
549+
has_fork_support = hasattr(os, "fork") and not (
550+
is_emscripten
551+
or is_wasi
552+
or is_apple_mobile
553+
)
545554

546555
def requires_fork():
547556
return unittest.skipUnless(has_fork_support, "requires working os.fork()")
548557

549-
has_subprocess_support = not is_emscripten and not is_wasi
558+
has_subprocess_support = not (
559+
is_emscripten
560+
or is_wasi
561+
or is_apple_mobile
562+
)
550563

551564
def requires_subprocess():
552565
"""Used for subprocess, os.spawn calls, fd inheritance"""
553566
return unittest.skipUnless(has_subprocess_support, "requires subprocess support")
554567

555568
# Emscripten's socket emulation and WASI sockets have limitations.
556-
has_socket_support = not is_emscripten and not is_wasi
569+
has_socket_support = not (
570+
is_emscripten
571+
or is_wasi
572+
)
557573

558574
def requires_working_socket(*, module=False):
559575
"""Skip tests or modules that require working sockets

0 commit comments

Comments
 (0)