[Zope3-checkins] SVN: Zope3/trunk/src/zope/server/ Fixed a bug in ServerBase and added a regression test.

Marius Gedminas marius at pov.lt
Wed Feb 16 12:57:19 EST 2005


Log message for revision 29165:
  Fixed a bug in ServerBase and added a regression test.
  
  

Changed:
  U   Zope3/trunk/src/zope/server/serverbase.py
  A   Zope3/trunk/src/zope/server/tests/test_serverbase.py

-=-
Modified: Zope3/trunk/src/zope/server/serverbase.py
===================================================================
--- Zope3/trunk/src/zope/server/serverbase.py	2005-02-16 17:33:17 UTC (rev 29164)
+++ Zope3/trunk/src/zope/server/serverbase.py	2005-02-16 17:57:19 UTC (rev 29165)
@@ -49,8 +49,8 @@
         self.bind((ip, port))
         self.verbose = verbose
         self.hit_log = hit_log
+        self.logger = logging.getLogger(self.__class__.__name__)
         self.server_name = self.computeServerName(ip)
-        self.logger = logging.getLogger(self.__class__.__name__)
 
         if start:
             self.accept_connections()

Added: Zope3/trunk/src/zope/server/tests/test_serverbase.py
===================================================================
--- Zope3/trunk/src/zope/server/tests/test_serverbase.py	2005-02-16 17:33:17 UTC (rev 29164)
+++ Zope3/trunk/src/zope/server/tests/test_serverbase.py	2005-02-16 17:57:19 UTC (rev 29165)
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Tests for zope.server.serverbase
+
+$Id$
+"""
+import unittest
+
+from zope.testing import doctest
+
+
+def doctest_ServerBase():
+    r"""Regression test for ServerBase
+
+    Bug: if the `ip` argument of ServerBase is a string containing a numberic
+    IP address, and the verbose argument is enabled, ServerBase.__init__
+    would try to use self.logger before it was initialized.
+
+    We will use a subclass of ServerBase so that unit tests do not actually try
+    to bind to ports.
+
+        >>> from zope.server.serverbase import ServerBase
+        >>> class ServerBaseForTest(ServerBase):
+        ...     def bind(self, (ip, port)):
+        ...         print "Listening on %s:%d" % (ip or '*', port)
+        >>> sb = ServerBaseForTest('127.0.0.1', 80, start=False, verbose=True)
+        Listening on 127.0.0.1:80
+
+    """
+
+
+def test_suite():
+    return doctest.DocTestSuite()
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')


Property changes on: Zope3/trunk/src/zope/server/tests/test_serverbase.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Zope3-Checkins mailing list