Commit 91081508 authored by Tres Seaver's avatar Tres Seaver

Suppress deprecation output for test of a known-to-be-deprecated feature.

parent 6d23d8ff
...@@ -134,8 +134,9 @@ class FCGIServerFactory(ServerFactory): ...@@ -134,8 +134,9 @@ class FCGIServerFactory(ServerFactory):
def __init__(self, section): def __init__(self, section):
import warnings import warnings
warnings.warn("Using FastCGI is deprecated. You should use mod_proxy " + warnings.warn("Using FastCGI is deprecated. You should use mod_proxy "
"to run Zope with Apache", DeprecationWarning) "to run Zope with Apache", DeprecationWarning,
stacklevel=2)
import socket import socket
......
...@@ -68,7 +68,38 @@ class BaseTest(unittest.TestCase): ...@@ -68,7 +68,38 @@ class BaseTest(unittest.TestCase):
self.assertEqual(factory.port, 9300 + port) 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): def load_unix_domain_factory(self, text):
fn = TEMPFILENAME fn = TEMPFILENAME
...@@ -147,6 +178,7 @@ class ZServerConfigurationTestCase(BaseTest): ...@@ -147,6 +178,7 @@ class ZServerConfigurationTestCase(BaseTest):
ZServer.datatypes.PCGIServerFactory)) ZServer.datatypes.PCGIServerFactory))
def test_fcgi_factory(self): def test_fcgi_factory(self):
self._trap_warning_output()
factory = self.load_factory("""\ factory = self.load_factory("""\
<fast-cgi> <fast-cgi>
address 83 address 83
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment