          request.makefile = lambda *args, **kwargs: BytesIO()
  
          handler = WSGIRequestHandler(request, '192.168.0.2', None)
  
          _stderr = sys.stderr
          sys.stderr = StringIO()
          try:
              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()
 
</s> remove                 sys.stderr.getvalue()
 </s> add                 stderr.getvalue() </s> remove         finally:
            sys.stderr = _stderr
 </s> add  </s> remove         finally:
            output = sys.stdout.getvalue()
            sys.stdout, sys.stderr = old_stdout, old_stderr
        self.assertEqual(output, "All right, let's dance Rock'n'Roll.\n")
 </s> add         self.assertEqual(stdout.getvalue(), "All right, let's dance Rock'n'Roll.\n") </s> remove         old_stderr = sys.stderr
        sys.stderr = err = StringIO()
        try:
            with self.assertRaises(SystemExit):
                management.ManagementUtility(['manage.py', 'dance', '--example=raise']).execute()
        finally:
            sys.stderr = old_stderr
        self.assertIn("CommandError", err.getvalue())
 </s> add         with captured_stderr() as stderr, self.assertRaises(SystemExit):
            management.ManagementUtility(['manage.py', 'dance', '--example=raise']).execute()
        self.assertIn("CommandError", stderr.getvalue()) </s> remove         old_stdout, old_stderr = sys.stdout, sys.stderr
        sys.stdout, sys.stderr = StringIO(), StringIO()
        try:
 </s> add         with captured_stdout() as stdout, captured_stderr():
        with captured_stderr() as stderr:
          request.makefile = lambda *args, **kwargs: BytesIO()
  
          handler = WSGIRequestHandler(request, '192.168.0.2', None)
  
        with captured_stderr() as stderr:
        with captured_stderr() as stderr:
        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()
keep keep keep keep replace replace replace keep keep keep keep keep
 Fixed #23930 -- Added copies of captured_std* managers from CPython's test.support.

StringIO import was adapted for compatibility with Python 2. 
tests/servers/test_basehttp.py