Merge "Capture stdout in for test_wsgi:test_debug"

This commit is contained in:
Jenkins
2016-09-26 16:58:30 +00:00
committed by Gerrit Code Review

View File

@@ -19,7 +19,9 @@
Test WSGI basics and provide some helper functions for other WSGI tests.
"""
import fixtures
import routes
from six.moves import StringIO
import webob
from nova import test
@@ -29,6 +31,11 @@ from nova import wsgi
class Test(test.NoDBTestCase):
def test_debug(self):
"""This tests optional middleware we have which dumps
the requests to stdout.
"""
self.output = StringIO()
self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.output))
class Application(wsgi.Application):
"""Dummy application to test debug."""
@@ -40,6 +47,9 @@ class Test(test.NoDBTestCase):
application = wsgi.Debug(Application())
result = webob.Request.blank('/').get_response(application)
self.assertEqual(result.body, b"Test result")
self.assertIn(
'**************************************** REQUEST ENVIRON',
self.output.getvalue())
def test_router(self):