          sys.argv = input_str.split()
  
      def _run_autocomplete(self):
          util = ManagementUtility(argv=sys.argv)
          try:
              util.autocomplete()
          except SystemExit:
              pass
          return self.output.getvalue().strip().split('\n')
  
      def test_django_admin_py(self):
          "django_admin.py will autocomplete option flags"
          self._user_input('django-admin sqlall --verb')
          output = self._run_autocomplete()
 
</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_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         self.output = StringIO()
        self.old_stdout = sys.stdout
        sys.stdout = self.output
 </s> add  </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         _stderr = sys.stderr
        sys.stderr = StringIO()
        try:
 </s> add         with captured_stderr() as stderr:
        with captured_stdout() as stdout:
            try:
                util.autocomplete()
            except SystemExit:
                pass
        return stdout.getvalue().strip().split('\n')
          sys.argv = input_str.split()
  
      def _run_autocomplete(self):
          util = ManagementUtility(argv=sys.argv)
        with captured_stdout() as stdout:
            try:
                util.autocomplete()
            except SystemExit:
                pass
        return stdout.getvalue().strip().split('\n')
        with captured_stdout() as stdout:
            try:
                util.autocomplete()
            except SystemExit:
                pass
        return stdout.getvalue().strip().split('\n')
        with captured_stdout() as stdout:
            try:
                util.autocomplete()
            except SystemExit:
                pass
        return stdout.getvalue().strip().split('\n')
        with captured_stdout() as stdout:
            try:
                util.autocomplete()
            except SystemExit:
                pass
        return stdout.getvalue().strip().split('\n')
        with captured_stdout() as stdout:
            try:
                util.autocomplete()
            except SystemExit:
                pass
        return stdout.getvalue().strip().split('\n')
  
      def test_django_admin_py(self):
          "django_admin.py will autocomplete option flags"
          self._user_input('django-admin sqlall --verb')
          output = self._run_autocomplete()
keep keep keep keep replace replace 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/bash_completion/tests.py