diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2017-02-13 20:06:44 +0700 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2017-02-13 20:09:01 +0700 |
commit | 99b5c56c04f3da4cda1ac65687265dfeb6c624dd (patch) | |
tree | 99723af9bc46c8f4162a5aea69fb2d21153504e6 | |
parent | 0edf0c99959bab4d5f43eec315484d1e1581644a (diff) |
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
-rwxr-xr-x | osmopy/obscvty.py | 5 | ||||
-rw-r--r-- | 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) |