Fixed #23930 -- Added copies of captured_std* managers from CPython's test.support.

StringIO import was adapted for compatibility with Python 2.
This commit is contained in:
wrwrwr 2014-11-28 23:47:53 +01:00 committed by Tim Graham
parent c8dcded930
commit 6dbe979b4d
7 changed files with 76 additions and 60 deletions

View file

@ -1,10 +1,9 @@
import sys
from django.core.handlers.wsgi import WSGIRequest
from django.core.servers.basehttp import WSGIRequestHandler
from django.test import TestCase
from django.test.client import RequestFactory
from django.utils.six import BytesIO, StringIO
from django.test.utils import captured_stderr
from django.utils.six import BytesIO
class WSGIRequestHandlerTestCase(TestCase):
@ -14,14 +13,10 @@ class WSGIRequestHandlerTestCase(TestCase):
handler = WSGIRequestHandler(request, '192.168.0.2', None)
_stderr = sys.stderr
sys.stderr = StringIO()
try:
with captured_stderr() as stderr:
handler.log_message("GET %s %s", str('\x16\x03'), "4")
self.assertIn(
"You're accessing the developement server over HTTPS, "
"but it only supports HTTP.",
sys.stderr.getvalue()
stderr.getvalue()
)
finally:
sys.stderr = _stderr