Skip to content

Commit ff5b79d

Browse files
committed
Fixed failing unittest when isotp module not installed
1 parent 9fcd722 commit ff5b79d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

udsoncan/connections.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class IsoTPConnection(BaseConnection):
217217
218218
"""
219219
def __init__(self, interface, rxid, txid, name=None, tpsock=None):
220-
import isotp
220+
221221
BaseConnection.__init__(self, name)
222222

223223
self.interface=interface
@@ -228,7 +228,11 @@ def __init__(self, interface, rxid, txid, name=None, tpsock=None):
228228
self.opened = False
229229

230230
self.rxthread = threading.Thread(target=self.rxthread_task)
231-
self.tpsock = isotp.socket(timeout=0.1) if tpsock is None else tpsock
231+
if tpsock is None:
232+
import isotp
233+
self.tpsock = isotp.socket(timeout=0.1)
234+
else:
235+
self.tpsock = tpsock
232236

233237

234238
def open(self):

0 commit comments

Comments
 (0)