Capture stdout in for test_wsgi:test_debug
This adds stdout capture, and verification for the wsgi.Debug middleware test. It was previously untested, and spewed stdout into the test output stream. Change-Id: I564d04c7d39df8bf0ee02486c4bb47161fc241c1
This commit is contained in:
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user