[Zodb-checkins] SVN: zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py Do not hide the socket exception in testRunIgnoresParentSignals

Marius Gedminas cvs-admin at zope.org
Thu Feb 14 11:15:45 UTC 2013


Log message for revision 129395:
  Do not hide the socket exception in testRunIgnoresParentSignals
  
  Explicitly close the socket to avoid ResourceWarnings.
  
  Avoid deprecated self.assert_ spelling.

Changed:
  U   zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py

-=-
Modified: zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py
===================================================================
--- zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py	2013-02-14 11:15:42 UTC (rev 129394)
+++ zdaemon/branches/py3/src/zdaemon/tests/testzdrun.py	2013-02-14 11:15:45 UTC (rev 129395)
@@ -237,8 +237,10 @@
             os.kill(zdctlpid, signal.SIGINT)
             time.sleep(0.25)
             # Make sure the child is still responsive.
-            response = send_action('status\n', zdrun_socket)
-            self.assert_(response is not None and '\n' in response)
+            response = send_action('status\n', zdrun_socket,
+                                   raise_on_error=True)
+            self.assertTrue(b'\n' in response,
+                            'no newline in response: ' + repr(response))
             # Kill the process.
             send_action('exit\n', zdrun_socket)
         finally:
@@ -413,7 +415,7 @@
         self.assertEqual([('chown', path, 27, 28)], calls)
 
 
-def send_action(action, sockname):
+def send_action(action, sockname, raise_on_error=False):
     """Send an action to the zdrun server and return the response.
 
     Return None if the server is not up or any other error happened.
@@ -437,7 +439,11 @@
             # domain socket filename, we want to make MacOS users aware
             # of the actual problem
             raise
+        if raise_on_error:
+            raise
         return None
+    finally:
+        sock.close()
 
 def test_suite():
     suite = unittest.TestSuite()



More information about the Zodb-checkins mailing list