[Zope-Checkins] SVN: Zope/trunk/lib/python/ZServer/ Suppress deprecation output for test of a known-to-be-deprecated feature.

Tres Seaver tseaver at palladion.com
Sun Dec 18 20:57:10 EST 2005


Log message for revision 40880:
  Suppress deprecation output for test of a known-to-be-deprecated feature.

Changed:
  U   Zope/trunk/lib/python/ZServer/datatypes.py
  U   Zope/trunk/lib/python/ZServer/tests/test_config.py

-=-
Modified: Zope/trunk/lib/python/ZServer/datatypes.py
===================================================================
--- Zope/trunk/lib/python/ZServer/datatypes.py	2005-12-18 22:08:21 UTC (rev 40879)
+++ Zope/trunk/lib/python/ZServer/datatypes.py	2005-12-19 01:57:10 UTC (rev 40880)
@@ -134,8 +134,9 @@
     def __init__(self, section):
 
         import warnings
-        warnings.warn("Using FastCGI is deprecated. You should use mod_proxy " +
-                      "to run Zope with Apache", DeprecationWarning)
+        warnings.warn("Using FastCGI is deprecated. You should use mod_proxy " 
+                      "to run Zope with Apache", DeprecationWarning,
+                      stacklevel=2)
 
 
         import socket

Modified: Zope/trunk/lib/python/ZServer/tests/test_config.py
===================================================================
--- Zope/trunk/lib/python/ZServer/tests/test_config.py	2005-12-18 22:08:21 UTC (rev 40879)
+++ Zope/trunk/lib/python/ZServer/tests/test_config.py	2005-12-19 01:57:10 UTC (rev 40880)
@@ -68,8 +68,39 @@
             self.assertEqual(factory.port, 9300 + port)
 
 
-class ZServerConfigurationTestCase(BaseTest):
+class WarningInterceptor:
 
+    _old_stderr = None
+    _our_stderr_stream = None
+
+    def _trap_warning_output( self ):
+
+        if self._old_stderr is not None:
+            return
+
+        import sys
+        from StringIO import StringIO
+
+        self._old_stderr = sys.stderr
+        self._our_stderr_stream = sys.stderr = StringIO()
+
+    def _free_warning_output( self ):
+
+        if self._old_stderr is None:
+            return
+
+        import sys
+        sys.stderr = self._old_stderr
+
+class ZServerConfigurationTestCase(BaseTest, WarningInterceptor):
+
+    def setUp(self):
+        BaseTest.setUp(self)
+
+    def tearDown(self):
+        self._free_warning_output()
+        BaseTest.tearDown(self)
+
     def load_unix_domain_factory(self, text):
         fn = TEMPFILENAME
         f = open(fn, 'w')
@@ -147,6 +178,7 @@
                                 ZServer.datatypes.PCGIServerFactory))
 
     def test_fcgi_factory(self):
+        self._trap_warning_output()
         factory = self.load_factory("""\
             <fast-cgi>
               address 83



More information about the Zope-Checkins mailing list