Skip to content

Commit

Permalink
Make clone tests do the detection dance
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed May 2, 2024
1 parent f56d220 commit b7ab603
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
LOG = logging.getLogger(__name__)


class SerialException(Exception):
pass


class SerialNone:
def flush(self):
pass
Expand Down Expand Up @@ -39,10 +43,10 @@ def __str__(self):

class SerialError(SerialNone):
def read(self, size=None):
raise Exception("Foo")
raise SerialException("Foo")

def write(self, data):
raise Exception("Bar")
raise SerialException("Bar")


class SerialGarbage(SerialNone):
Expand Down Expand Up @@ -87,6 +91,18 @@ def _test_with_serial(self, serial):
# behavior on init.
LOG.info('Initializing radio with fake serial; Radio should not fail')
orig_mmap = self.parent._mmap

try:
cls = self.RADIO_CLASS.detect_from_serial(serial)
if cls and cls != self.RADIO_CLASS:
self.fail('Radio detection did not return self')
except NotImplementedError:
pass
except errors.RadioError:
pass
except SerialException:
pass

self.radio = self.RADIO_CLASS(serial)
self.radio._mmap = orig_mmap
self.radio.status_fn = lambda s: True
Expand Down

0 comments on commit b7ab603

Please sign in to comment.