def test_open(self): tpsock = StubbedIsoTPSocket() self.assertFalse(tpsock.bound) tpsock.bind(interface=u'vcan0', rxid=0x100, txid=0x101) self.assertTrue(tpsock.bound) tpsock.close() self.assertFalse(tpsock.bound)
def test_empty_on_close(self): tpsock1 = StubbedIsoTPSocket() tpsock2 = StubbedIsoTPSocket(timeout=0.2) tpsock1.bind(interface=u'vcan0', rxid=0x400, txid=0x401) tpsock2.bind(interface=u'vcan0', rxid=0x401, txid=0x400) payload = "\x01\x02\x03\x04" tpsock1.send(payload) tpsock2.close() with self.assertRaises(socket.timeout): tpsock2.recv()