[MERGED] python/osmo-python-tests[master]: vty: Close the vty sockets at the end of each test

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Mon Feb 13 13:31:08 UTC 2017


Holger Freyther has submitted this change and it was merged.

Change subject: vty: Close the vty sockets at the end of each test
......................................................................


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
---
M osmopy/obscvty.py
M osmopy/osmotestvty.py
2 files changed, 4 insertions(+), 2 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Holger Freyther: Verified



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 @@
         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 @@
         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)
 

-- 
To view, visit https://gerrit.osmocom.org/1812
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6
Gerrit-PatchSet: 1
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list