|
1 | 1 | import unittest
|
| 2 | +from unittest import mock |
2 | 3 | from test import support
|
3 | 4 | from test.support import (
|
4 | 5 | is_apple, os_helper, refleak_helper, socket_helper, threading_helper
|
@@ -2682,13 +2683,23 @@ def testBadL2capAddr(self):
|
2682 | 2683 | with self.assertRaises(OSError):
|
2683 | 2684 | f.bind((socket.BDADDR_ANY.encode(), 0x1001))
|
2684 | 2685 |
|
2685 |
| - @unittest.skipIf(sys.platform == "win32", "test does not work on windows") |
2686 | 2686 | def testBindRfcommSocket(self):
|
2687 | 2687 | with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) as s:
|
2688 | 2688 | 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)) |
2690 | 2694 | 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) |
2692 | 2703 |
|
2693 | 2704 | def testBadRfcommAddr(self):
|
2694 | 2705 | with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) as s:
|
|
0 commit comments