Skip to content

Commit 0aca6a8

Browse files
authored
Merge pull request RustPython#3840 from fanninpm/socket-constants
Add `_socket` constants from CPython 3.10
2 parents c022350 + 0b1a542 commit 0aca6a8

File tree

2 files changed

+613
-3
lines changed

2 files changed

+613
-3
lines changed

Lib/test/test_socket.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,8 @@ def test_sock_ioctl(self):
13891389
@unittest.skipUnless(os.name == "nt", "Windows specific")
13901390
@unittest.skipUnless(hasattr(socket, 'SIO_LOOPBACK_FAST_PATH'),
13911391
'Loopback fast path support required for this test')
1392+
# TODO: RUSTPYTHON, AttributeError: 'socket' object has no attribute 'ioctl'
1393+
@unittest.expectedFailure
13921394
def test_sio_loopback_fast_path(self):
13931395
s = socket.socket()
13941396
self.addCleanup(s.close)
@@ -1733,6 +1735,10 @@ def test_socket_consistent_sock_type(self):
17331735
s.setblocking(False)
17341736
self.assertEqual(s.type, socket.SOCK_STREAM)
17351737

1738+
# TODO: RUSTPYTHON, AssertionError: 526337 != <SocketKind.SOCK_STREAM: 1>
1739+
if sys.platform == "linux":
1740+
test_socket_consistent_sock_type = unittest.expectedFailure(test_socket_consistent_sock_type)
1741+
17361742
def test_unknown_socket_family_repr(self):
17371743
# Test that when created with a family that's not one of the known
17381744
# AF_*/SOCK_* constants, socket.family just returns the number.
@@ -1873,6 +1879,8 @@ def testCrucialConstants(self):
18731879

18741880
@unittest.skipUnless(hasattr(socket, "CAN_BCM"),
18751881
'socket.CAN_BCM required for this test.')
1882+
# TODO: RUSTPYTHON, AttributeError: module 'socket' has no attribute 'CAN_BCM_TX_SETUP'
1883+
@unittest.expectedFailure
18761884
def testBCMConstants(self):
18771885
socket.CAN_BCM
18781886

@@ -1913,12 +1921,16 @@ def testCreateBCMSocket(self):
19131921
with socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM) as s:
19141922
pass
19151923

1924+
# TODO: RUSTPYTHON, OSError: bind(): bad family
1925+
@unittest.expectedFailure
19161926
def testBindAny(self):
19171927
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
19181928
address = ('', )
19191929
s.bind(address)
19201930
self.assertEqual(s.getsockname(), address)
19211931

1932+
# TODO: RUSTPYTHON, AssertionError: "interface name too long" does not match "bind(): bad family"
1933+
@unittest.expectedFailure
19221934
def testTooLongInterfaceName(self):
19231935
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
19241936
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
@@ -4377,6 +4389,8 @@ def testSetBlocking_overflow(self):
43774389
@unittest.skipUnless(hasattr(socket, 'SOCK_NONBLOCK'),
43784390
'test needs socket.SOCK_NONBLOCK')
43794391
@support.requires_linux_version(2, 6, 28)
4392+
# TODO: RUSTPYTHON, AssertionError: None != 0
4393+
@unittest.expectedFailure
43804394
def testInitNonBlocking(self):
43814395
# create a socket with SOCK_NONBLOCK
43824396
self.serv.close()
@@ -5395,6 +5409,8 @@ class InheritanceTest(unittest.TestCase):
53955409
@unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"),
53965410
"SOCK_CLOEXEC not defined")
53975411
@support.requires_linux_version(2, 6, 28)
5412+
# TODO: RUSTPYTHON, AssertionError: 524289 != <SocketKind.SOCK_STREAM: 1>
5413+
@unittest.expectedFailure
53985414
def test_SOCK_CLOEXEC(self):
53995415
with socket.socket(socket.AF_INET,
54005416
socket.SOCK_STREAM | socket.SOCK_CLOEXEC) as s:
@@ -5487,6 +5503,8 @@ def checkNonblock(self, s, nonblock=True, timeout=0.0):
54875503
self.assertTrue(s.getblocking())
54885504

54895505
@support.requires_linux_version(2, 6, 28)
5506+
# TODO: RUSTPYTHON, AssertionError: 2049 != <SocketKind.SOCK_STREAM: 1>
5507+
@unittest.expectedFailure
54905508
def test_SOCK_NONBLOCK(self):
54915509
# a lot of it seems silly and redundant, but I wanted to test that
54925510
# changing back and forth worked ok
@@ -5910,6 +5928,8 @@ def create_alg(self, typ, name):
59105928
# bpo-31705: On kernel older than 4.5, sendto() failed with ENOKEY,
59115929
# at least on ppc64le architecture
59125930
@support.requires_linux_version(4, 5)
5931+
# TODO: RUSTPYTHON, OSError: bind(): bad family
5932+
@unittest.expectedFailure
59135933
def test_sha256(self):
59145934
expected = bytes.fromhex("ba7816bf8f01cfea414140de5dae2223b00361a396"
59155935
"177a9cb410ff61f20015ad")
@@ -5927,6 +5947,8 @@ def test_sha256(self):
59275947
op.send(b'')
59285948
self.assertEqual(op.recv(512), expected)
59295949

5950+
# TODO: RUSTPYTHON, OSError: bind(): bad family
5951+
@unittest.expectedFailure
59305952
def test_hmac_sha1(self):
59315953
expected = bytes.fromhex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")
59325954
with self.create_alg('hash', 'hmac(sha1)') as algo:
@@ -5939,6 +5961,8 @@ def test_hmac_sha1(self):
59395961
# Although it should work with 3.19 and newer the test blocks on
59405962
# Ubuntu 15.10 with Kernel 4.2.0-19.
59415963
@support.requires_linux_version(4, 3)
5964+
# TODO: RUSTPYTHON, OSError: bind(): bad family
5965+
@unittest.expectedFailure
59425966
def test_aes_cbc(self):
59435967
key = bytes.fromhex('06a9214036b8a15b512e03d534120006')
59445968
iv = bytes.fromhex('3dafba429d9eb430b422da802c9fac41')
@@ -5980,6 +6004,8 @@ def test_aes_cbc(self):
59806004
self.assertEqual(dec, msg * multiplier)
59816005

59826006
@support.requires_linux_version(4, 9) # see issue29324
6007+
# TODO: RUSTPYTHON, OSError: bind(): bad family
6008+
@unittest.expectedFailure
59836009
def test_aead_aes_gcm(self):
59846010
key = bytes.fromhex('c939cc13397c1d37de6ae0e1cb7c423c')
59856011
iv = bytes.fromhex('b3d8cc017cbb89b39e0f67e2')
@@ -6043,6 +6069,8 @@ def test_aead_aes_gcm(self):
60436069
self.assertEqual(plain, res[assoclen:])
60446070

60456071
@support.requires_linux_version(4, 3) # see test_aes_cbc
6072+
# TODO: RUSTPYTHON, OSError: bind(): bad family
6073+
@unittest.expectedFailure
60466074
def test_drbg_pr_sha256(self):
60476075
# deterministic random bit generator, prediction resistance, sha256
60486076
with self.create_alg('rng', 'drbg_pr_sha256') as algo:
@@ -6053,6 +6081,8 @@ def test_drbg_pr_sha256(self):
60536081
rn = op.recv(32)
60546082
self.assertEqual(len(rn), 32)
60556083

6084+
# TODO: RUSTPYTHON, AttributeError: 'socket' object has no attribute 'sendmsg_afalg'
6085+
@unittest.expectedFailure
60566086
def test_sendmsg_afalg_args(self):
60576087
sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
60586088
with sock:
@@ -6071,6 +6101,8 @@ def test_sendmsg_afalg_args(self):
60716101
with self.assertRaises(TypeError):
60726102
sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)
60736103

6104+
# TODO: RUSTPYTHON, OSError: bind(): bad family
6105+
@unittest.expectedFailure
60746106
def test_length_restriction(self):
60756107
# bpo-35050, off-by-one error in length check
60766108
sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)

0 commit comments

Comments
 (0)