Parcourir la source

[1275] modify test_utils.py

 - remove the finally statement from the run method in the MockMsgq class.
   Because it is found that it doesn't actually work even if it is there.  And
   also it is found that self.msgq.shutdown() doesn't work even though outside
   of the thread.

 - instead of self.msgq.shutdown(), add the removal of the socket file into the
   shutdown method in the BaseModules class
Naoki Kambe il y a 13 ans
Parent
commit
5ab87bf933
1 fichiers modifiés avec 8 ajouts et 6 suppressions
  1. 8 6
      src/bin/stats/tests/test_utils.py

+ 8 - 6
src/bin/stats/tests/test_utils.py

@@ -105,14 +105,9 @@ class MockMsgq:
             self.msgq.run()
         except Exception:
             pass
-        finally:
-            # explicitly shut down the socket of the msgq before
-            # shutting down the msgq
-            self.msgq.listen_socket.shutdown(msgq.socket.SHUT_RDWR)
-            self.msgq.shutdown()
 
     def shutdown(self):
-        # do nothing for avoiding shutting down the msgq twice
+        # do nothing
         pass
 
 class MockCfgmgr:
@@ -362,3 +357,10 @@ class BaseModules:
         self.cfgmgr.shutdown()
         # MockMsgq
         self.msgq.shutdown()
+        # remove the unused socket file
+        socket_file = self.msgq.server.msgq.socket_file
+        try:
+            if os.path.exists(socket_file):
+                os.remove(socket_file)
+        except OSError:
+            pass