8000 Try to run the RFCOMM test on Windows if possible. · python/cpython@9266445 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9266445

Browse files
Try to run the RFCOMM test on Windows if possible.
1 parent 94c9287 commit 9266445

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Lib/test/test_socket.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
from unittest import mock
23
from test import support
34
from test.support import (
45
is_apple, os_helper, refleak_helper, socket_helper, threading_helper
@@ -2682,13 +2683,23 @@ def testBadL2capAddr(self):
26822683
with self.assertRaises(OSError):
26832684
f.bind((socket.BDADDR_ANY.encode(), 0x1001))
26842685

2685-
@unittest.skipIf(sys.platform == "win32", "test does not work on windows")
26862686
def testBindRfcommSocket(self):
26872687
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) as s:
26882688
channel = 0
2689-
s.bind((socket.BDADDR_ANY, channel))
2689+
try:
2690+
s.bind((socket.BDADDR_ANY, channel))
2691+
except OSError as err:
A591
2692+
if sys.platform == 'win32' and err.winerror == 10050:
2693+
self.skipTest(str(err))
26902694
addr = s.getsockname()
2691-
self.assertEqual(addr, (socket.BDADDR_ANY, channel))
2695+
self.assertEqual(addr, (mock.ANY, channel))
2696+
self.assertRegex(addr[0], r'(?i)[0-9a-f]{2}(?::[0-9a-f]{2}){4}')
2697+
if sys.platform != 'win32':
2698+
self.assertEqual(addr, (socket.BDADDR_ANY, channel))
2699+
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) as s:
2700+
s.bind(addr)
2701+
addr2 = s.getsockname()
2702+
self.assertEqual(addr2, addr)
26922703

26932704
def testBadRfcommAddr(self):
26942705
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) as s:

0 commit comments

Comments
 (0)
0