From 0ea0b13991e31c39d8cdd29d6f872950eee73262 Mon Sep 17 00:00:00 2001 From: "Ralph Hart, Jr" Date: Wed, 22 Jun 2022 23:17:52 -0400 Subject: [PATCH] bluetooth.py: handle discover_devices returning bytes (instead of str) --- nxt/backend/bluetooth.py | 2 ++ tests/test_backend_bluetooth.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nxt/backend/bluetooth.py b/nxt/backend/bluetooth.py index 4521c3d..2196195 100644 --- a/nxt/backend/bluetooth.py +++ b/nxt/backend/bluetooth.py @@ -122,6 +122,8 @@ def find(self, host=None, name=None, **kwargs): else: devhost, devname = dev, None if (host is None or devhost == host) and (name is None or devname == name): + if type(devhost) is bytes: + devhost = devhost.decode('utf8') sock = BluetoothSock(self._bluetooth, devhost) try: brick = sock.connect() diff --git a/tests/test_backend_bluetooth.py b/tests/test_backend_bluetooth.py index 0eaacd9..49f0245 100644 --- a/tests/test_backend_bluetooth.py +++ b/tests/test_backend_bluetooth.py @@ -85,7 +85,7 @@ def test_bluetooth(mbluetooth, mbluetooth_import, msock): backend = nxt.backend.bluetooth.get_backend() # Find brick. mbluetooth.discover_devices.return_value = [ - "00:01:02:03:04:05", + b"00:01:02:03:04:05", ] bricks = list(backend.find(blah="blah")) assert len(bricks) == 1