Skip to content

Commit 334dee6

Browse files
committed
virtual smoothie throws exception if read/write without .open() called prior
1 parent 9e095ce commit 334dee6

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

opentrons/drivers/virtual_smoothie.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,16 @@ def process_command(self, command):
268268
'Command {} is not supported'.format(command))
269269

270270
def write(self, data):
271+
if not self.isOpen():
272+
raise Exception('Virtual Smoothie no currently connected')
271273
if not isinstance(data, str):
272274
data = data.decode('utf-8')
273275
# make it async later
274276
self.process_command(data)
275277

276278
def readline(self):
279+
if not self.isOpen():
280+
raise Exception('Virtual Smoothie no currently connected')
277281
if len(self.responses) > 0:
278282
return self.responses.pop().encode('utf-8')
279283
else:

tests/opentrons/drivers/test_virtual_smoothie.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def setUp(self):
1919
}
2020
}
2121
self.s = VirtualSmoothie(port=None, options=options)
22+
self.s.open()
2223

2324
def test_version(self):
2425
self.s.write('version')

0 commit comments

Comments
 (0)