rfc2217: improve tests and fix bugs
diff --git a/serial/rfc2217.py b/serial/rfc2217.py
index 4550ccf..be290ce 100644
--- a/serial/rfc2217.py
+++ b/serial/rfc2217.py
@@ -378,6 +378,11 @@
BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
9600, 19200, 38400, 57600, 115200)
+ def __init__(self, *args, **kwargs):
+ super(Serial, self).__init__(*args, **kwargs)
+ self._thread = None
+ self._socket = None
+
def open(self):
"""\
Open port with current settings. This may throw a SerialException
diff --git a/test/test_rfc2217.py b/test/test_rfc2217.py
index 05bee83..7fd9a6e 100644
--- a/test/test_rfc2217.py
+++ b/test/test_rfc2217.py
@@ -20,6 +20,16 @@
s = serial.serial_for_url('rfc2217://127.99.99.99:2217', do_not_open=True)
self.failUnlessRaises(serial.SerialException, s.open)
self.assertFalse(s.is_open)
+ s.close() # no errors expected
+ # invalid address
+ s = serial.serial_for_url('rfc2217://127goingtofail', do_not_open=True)
+ self.failUnlessRaises(serial.SerialException, s.open)
+ self.assertFalse(s.is_open)
+ s.close() # no errors expected
+ # close w/o open is also OK
+ s = serial.serial_for_url('rfc2217://irrelevant', do_not_open=True)
+ self.assertFalse(s.is_open)
+ s.close() # no errors expected
if __name__ == '__main__':