@@ -1199,8 +1199,8 @@ def testGetServBy(self):
1199
1199
# I've ordered this by protocols that have both a tcp and udp
1200
1200
# protocol, at least for modern Linuxes.
1201
1201
if (
1202
- sys .platform .startswith (( 'freebsd' , 'netbsd' , 'gnukfreebsd' ))
1203
- or sys . platform == 'linux'
1202
+ sys .platform .startswith (
1203
+ ( 'linux' , 'android' , 'freebsd' , 'netbsd' , 'gnukfreebsd' ))
1204
1204
or is_apple
1205
1205
):
1206
1206
# avoid the 'echo' service on this platform, as there is an
@@ -1218,8 +1218,7 @@ def testGetServBy(self):
1218
1218
raise OSError
1219
1219
# Try same call with optional protocol omitted
1220
1220
# Issue #26936: Android getservbyname() was broken before API 23.
1221
- if (not hasattr (sys , 'getandroidapilevel' ) or
1222
- sys .getandroidapilevel () >= 23 ):
1221
+ if (not support .is_android ) or sys .getandroidapilevel () >= 23 :
1223
1222
port2 = socket .getservbyname (service )
1224
1223
eq (port , port2 )
1225
1224
# Try udp, but don't barf if it doesn't exist
@@ -1577,8 +1576,7 @@ def testGetaddrinfo(self):
1577
1576
# port can be a string service name such as "http", a numeric
1578
1577
# port number or None
1579
1578
# Issue #26936: Android getaddrinfo() was broken before API level 23.
1580
- if (not hasattr (sys , 'getandroidapilevel' ) or
1581
- sys .getandroidapilevel () >= 23 ):
1579
+ if (not support .is_android ) or sys .getandroidapilevel () >= 23 :
1582
1580
socket .getaddrinfo (HOST , "http" )
1583
1581
socket .getaddrinfo (HOST , 80 )
1584
1582
socket .getaddrinfo (HOST , None )
@@ -3196,7 +3194,7 @@ def _testSendmsgTimeout(self):
3196
3194
# Linux supports MSG_DONTWAIT when sending, but in general, it
3197
3195
# only works when receiving. Could add other platforms if they
3198
3196
# support it too.
3199
- @skipWithClientIf (sys .platform not in {"linux" },
3197
+ @skipWithClientIf (sys .platform not in {"linux" , "android" },
3200
3198
"MSG_DONTWAIT not known to work on this platform when "
3201
3199
"sending" )
3202
3200
def testSendmsgDontWait (self ):
@@ -5634,7 +5632,7 @@ def test_setblocking_invalidfd(self):
5634
5632
sock .setblocking (False )
5635
5633
5636
5634
5637
- @unittest .skipUnless (sys .platform == 'linux' , 'Linux specific test' )
5635
+ @unittest .skipUnless (sys .platform in ( 'linux' , 'android' ) , 'Linux specific test' )
5638
5636
class TestLinuxAbstractNamespace (unittest .TestCase ):
5639
5637
5640
5638
UNIX_PATH_MAX = 108
@@ -5759,7 +5757,8 @@ def testUnencodableAddr(self):
5759
5757
self .addCleanup (os_helper .unlink , path )
5760
5758
self .assertEqual (self .sock .getsockname (), path )
5761
5759
5762
- @unittest .skipIf (sys .platform == 'linux' , 'Linux specific test' )
5760
+ @unittest .skipIf (sys .platform in ('linux' , 'android' ),
5761
+ 'Linux behavior is tested by TestLinuxAbstractNamespace' )
5763
5762
def testEmptyAddress (self ):
5764
5763
# Test that binding empty address fails.
5765
5764
self .assertRaises (OSError , self .sock .bind , "" )
0 commit comments