vty: Close the vty sockets at the end of each test

In the OpenBSC VTY tests it seems no one is calling
the command with close=True. So make sure the socket
is released. Modify _close_socket to be idempotent.

Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6
This commit is contained in:
Holger Hans Peter Freyther 2017-02-13 20:06:44 +07:00
parent 0edf0c9995
commit 99b5c56c04
2 changed files with 4 additions and 2 deletions

View File

@ -43,8 +43,9 @@ class VTYInteract(object):
self.last_node = ''
def _close_socket(self):
self.socket.close()
self.socket = None
if self.socket:
self.socket.close()
self.socket = None
def _is_end(self, text, ends):
"""

View File

@ -48,6 +48,7 @@ class TestVTY(unittest.TestCase):
self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)
def tearDown(self):
self.vty._close_socket()
self.vty = None
osmoutil.end_proc(self.proc)