From 99b5c56c04f3da4cda1ac65687265dfeb6c624dd Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 13 Feb 2017 20:06:44 +0700 Subject: 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 --- osmopy/obscvty.py | 5 +++-- osmopy/osmotestvty.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 2654f3d..3c9edb1 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -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): """ diff --git a/osmopy/osmotestvty.py b/osmopy/osmotestvty.py index 8d9f3c4..9f8dd0a 100644 --- a/osmopy/osmotestvty.py +++ b/osmopy/osmotestvty.py @@ -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) -- cgit v1.2.3