          shutil.copytree('canned_locale', 'locale')
          self.addCleanup(self._rmrf, os.path.join(self.test_dir, 'locale'))
  
      def test_command_help(self):
          old_stdout, old_stderr = sys.stdout, sys.stderr
          sys.stdout, sys.stderr = StringIO(), StringIO()
          try:
              # `call_command` bypasses the parser; by calling
              # `execute_from_command_line` with the help subcommand we
              # ensure that there are no issues with the parser itself.
              execute_from_command_line(['django-admin', 'help', 'compilemessages'])
          finally:
 
</s> remove         old_stdout, old_stderr = sys.stdout, sys.stderr
        sys.stdout, sys.stderr = StringIO(), StringIO()
        try:
 </s> add         with captured_stdout(), captured_stderr(): </s> remove         finally:
            sys.stdout, sys.stderr = old_stdout, old_stderr
 </s> add  </s> remove         finally:
            sys.stdout, sys.stderr = old_stdout, old_stderr
 </s> add  </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(): </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")
        with captured_stdout(), captured_stderr():
          shutil.copytree('canned_locale', 'locale')
          self.addCleanup(self._rmrf, os.path.join(self.test_dir, 'locale'))
  
      def test_command_help(self):
        with captured_stdout(), captured_stderr():
        with captured_stdout(), captured_stderr():
        with captured_stdout(), captured_stderr():
              # `call_command` bypasses the parser; by calling
              # `execute_from_command_line` with the help subcommand we
              # ensure that there are no issues with the parser itself.
              execute_from_command_line(['django-admin', 'help', 'compilemessages'])
          finally:
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/i18n/test_compilation.py