Description: skip Bluetooth tests when kernel lacks BT support
 The HAVE_BT gate previously only checked that socket.AF_BLUETOOTH exists
 and the bluetooth modules import successfully. On build systems where
 the Python constant is defined but the kernel does not actually support
 the Bluetooth protocol family, socket.socket(AF_BLUETOOTH, ...) raises
 OSError(97, "Address family not supported by protocol"), causing
 test_bt_wrong_mac to fail. Probe by attempting to create a Bluetooth
 socket so that HAVE_BT is only set when the kernel can actually use it.
Author: Sascha Steinbiss <satta@debian.org>
--- a/tests/test_bluetooth.py
+++ b/tests/test_bluetooth.py
@@ -16,8 +16,14 @@ if hasattr(socket, 'AF_BLUETOOTH'):
     try:
         from keysign.bluetoothoffer import BluetoothOffer
         from keysign.bluetoothreceive import BluetoothReceive, BluetoothError
+        # Probe that the kernel actually supports the Bluetooth protocol
+        # family; AF_BLUETOOTH may be defined even when no Bluetooth stack
+        # is available (e.g. build sandboxes), in which case socket()
+        # raises OSError(97, "Address family not supported by protocol").
+        socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM,
+                      socket.BTPROTO_RFCOMM).close()
         HAVE_BT = True
-    except ImportError:
+    except (ImportError, OSError):
         pass
 
