Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0: test suite is failing #365

Closed
kloczek opened this issue Jan 3, 2022 · 3 comments
Closed

2.0.0: test suite is failing #365

kloczek opened this issue Jan 3, 2022 · 3 comments

Comments

@kloczek
Copy link

kloczek commented Jan 3, 2022

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-argcomplete-2.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-argcomplete-2.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra test/test.py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0
collected 148 items

test/test.py FFFFFFFFF...FFF.FFFFFFFFFFF..FFFFF......x.........FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.x..xx..x........x.F....xs.......s.......    [100%]

================================================================================= FAILURES =================================================================================
__________________________________________________________________ TestArgcomplete.test_action_activation __________________________________________________________________

self = <test.test.TestArgcomplete testMethod=test_action_activation>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog bus ', point = '9', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}
t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>, cm = <unittest.case._AssertRaisesContext object at 0x7f3e59f40100>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
>               completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)

test/test.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def __call__(self, argument_parser, always_complete_options=True, exit_method=os._exit, output_stream=None,
                 exclude=None, validator=None, print_suppressed=False, append_space=None,
                 default_completer=FilesCompleter()):
        """
        :param argument_parser: The argument parser to autocomplete on
        :type argument_parser: :class:`argparse.ArgumentParser`
        :param always_complete_options:
            Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
            been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
            suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
            with no long variant will be suggested. If ``short``, short options and long options with no short variant
            will be suggested.
        :type always_complete_options: boolean or string
        :param exit_method:
            Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
            perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
        :type exit_method: callable
        :param exclude: List of strings representing options to be omitted from autocompletion
        :type exclude: iterable
        :param validator:
            Function to filter all completions through before returning (called with two string arguments, completion
            and prefix; return value is evaluated as a boolean)
        :type validator: callable
        :param print_suppressed:
            Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
        :type print_suppressed: boolean
        :param append_space:
            Whether to append a space to unique matches. The default is ``True``.
        :type append_space: boolean

        .. note::
            If you are not subclassing CompletionFinder to override its behaviors,
            use ``argcomplete.autocomplete()`` directly. It has the same signature as this method.

        Produces tab completions for ``argument_parser``. See module docs for more info.

        Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
        added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
        their execution is otherwise desirable.
        """
        self.__init__(argument_parser, always_complete_options=always_complete_options, exclude=exclude,
                      validator=validator, print_suppressed=print_suppressed, append_space=append_space,
                      default_completer=default_completer)

        if "_ARGCOMPLETE" not in os.environ:
            # not an argument completion invocation
            return

        global debug_stream
        try:
            debug_stream = os.fdopen(9, "w")
        except Exception:
            debug_stream = sys.stderr
        debug()

        if output_stream is None:
            filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME")
            if filename is not None:
                debug("Using output file {}".format(filename))
                output_stream = open(filename, "w")

        if output_stream is None:
            try:
                output_stream = os.fdopen(8, "w")
            except Exception:
                debug("Unable to open fd 8 for writing, quitting")
                exit_method(1)

        # print("", stream=debug_stream)
        # for v in "COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY _ARGCOMPLETE_COMP_WORDBREAKS COMP_WORDS".split():
        #     print(v, os.environ[v], stream=debug_stream)

        ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
        if len(ifs) != 1:
            debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
            exit_method(1)

        dfs = os.environ.get("_ARGCOMPLETE_DFS")
        if dfs and len(dfs) != 1:
            debug("Invalid value for DFS, quitting [{v}]".format(v=dfs))
            exit_method(1)

        comp_line = os.environ["COMP_LINE"]
        comp_point = int(os.environ["COMP_POINT"])

        cword_prequote, cword_prefix, cword_suffix, comp_words, last_wordbreak_pos = split_line(comp_line, comp_point)

        # _ARGCOMPLETE is set by the shell script to tell us where comp_words
        # should start, based on what we're completing.
        # 1: <script> [args]
        # 2: python <script> [args]
        # 3: python -m <module> [args]
        start = int(os.environ["_ARGCOMPLETE"]) - 1
        comp_words = comp_words[start:]

        if cword_prefix and cword_prefix[0] in self._parser.prefix_chars and "=" in cword_prefix:
            # Special case for when the current word is "--optional=PARTIAL_VALUE". Give the optional to the parser.
            comp_words.append(cword_prefix.split("=", 1)[0])

        debug("\nLINE: {!r}".format(comp_line),
              "\nPOINT: {!r}".format(comp_point),
              "\nPREQUOTE: {!r}".format(cword_prequote),
              "\nPREFIX: {!r}".format(cword_prefix),
              "\nSUFFIX: {!r}".format(cword_suffix),
              "\nWORDS:", comp_words)

        completions = self._get_completions(comp_words, cword_prefix, cword_prequote, last_wordbreak_pos)

        if dfs:
            display_completions = {key_part: value.replace(ifs, " ") if value else ""
                                   for key, value in self._display_completions.items()
                                   for key_part in key}
            completions = [dfs.join((key, display_completions.get(key) or "")) for key in completions]

        debug("\nReturning completions:", completions)
        output_stream.write(ifs.join(completions))
>       output_stream.flush()
E       OSError: [Errno 9] Bad file descriptor

argcomplete/__init__.py:242: OSError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/test/test.py", line 80, in run_completer
    completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/argcomplete/__init__.py", line 242, in __call__
    output_stream.flush()
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

self = <test.test.TestArgcomplete testMethod=test_action_activation>

    def test_action_activation(self):
        def make_parser():
            parser = ArgumentParser()
            parser.add_argument("var", choices=["bus", "car"])
            parser.add_argument("value", choices=["orange", "apple"])
            return parser

        expected_outputs = (
            ("prog ", ["bus", "car", "-h", "--help"]),
            ("prog bu", ["bus "]),
            ("prog bus ", ["apple", "orange", "-h", "--help"]),
            ("prog bus appl", ["apple "]),
            ("prog bus apple ", ["-h", "--help"]),
        )

        for cmd, output in expected_outputs:
>           self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))

test/test.py:203:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <test.test.TestArgcomplete testMethod=test_action_activation>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog bus ', point = '9', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}
t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>, cm = <unittest.case._AssertRaisesContext object at 0x7f3e59f40100>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
                completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
            if cm.exception.code != 0:
                raise Exception("Unexpected exit code %d" % cm.exception.code)
            t.seek(0)
>           return t.read().split(IFS)
E           OSError: [Errno 9] Bad file descriptor

test/test.py:84: OSError
__________________________________________________________ TestArgcomplete.test_action_activation_with_subparser ___________________________________________________________

self = <test.test.TestArgcomplete testMethod=test_action_activation_with_subparser>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59d61790>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
>               completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)

test/test.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def __call__(self, argument_parser, always_complete_options=True, exit_method=os._exit, output_stream=None,
                 exclude=None, validator=None, print_suppressed=False, append_space=None,
                 default_completer=FilesCompleter()):
        """
        :param argument_parser: The argument parser to autocomplete on
        :type argument_parser: :class:`argparse.ArgumentParser`
        :param always_complete_options:
            Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
            been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
            suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
            with no long variant will be suggested. If ``short``, short options and long options with no short variant
            will be suggested.
        :type always_complete_options: boolean or string
        :param exit_method:
            Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
            perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
        :type exit_method: callable
        :param exclude: List of strings representing options to be omitted from autocompletion
        :type exclude: iterable
        :param validator:
            Function to filter all completions through before returning (called with two string arguments, completion
            and prefix; return value is evaluated as a boolean)
        :type validator: callable
        :param print_suppressed:
            Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
        :type print_suppressed: boolean
        :param append_space:
            Whether to append a space to unique matches. The default is ``True``.
        :type append_space: boolean

        .. note::
            If you are not subclassing CompletionFinder to override its behaviors,
            use ``argcomplete.autocomplete()`` directly. It has the same signature as this method.

        Produces tab completions for ``argument_parser``. See module docs for more info.

        Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
        added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
        their execution is otherwise desirable.
        """
        self.__init__(argument_parser, always_complete_options=always_complete_options, exclude=exclude,
                      validator=validator, print_suppressed=print_suppressed, append_space=append_space,
                      default_completer=default_completer)

        if "_ARGCOMPLETE" not in os.environ:
            # not an argument completion invocation
            return

        global debug_stream
        try:
            debug_stream = os.fdopen(9, "w")
        except Exception:
            debug_stream = sys.stderr
        debug()

        if output_stream is None:
            filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME")
            if filename is not None:
                debug("Using output file {}".format(filename))
                output_stream = open(filename, "w")

        if output_stream is None:
            try:
                output_stream = os.fdopen(8, "w")
            except Exception:
                debug("Unable to open fd 8 for writing, quitting")
                exit_method(1)

        # print("", stream=debug_stream)
        # for v in "COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY _ARGCOMPLETE_COMP_WORDBREAKS COMP_WORDS".split():
        #     print(v, os.environ[v], stream=debug_stream)

        ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
        if len(ifs) != 1:
            debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
            exit_method(1)

        dfs = os.environ.get("_ARGCOMPLETE_DFS")
        if dfs and len(dfs) != 1:
            debug("Invalid value for DFS, quitting [{v}]".format(v=dfs))
            exit_method(1)

        comp_line = os.environ["COMP_LINE"]
        comp_point = int(os.environ["COMP_POINT"])

        cword_prequote, cword_prefix, cword_suffix, comp_words, last_wordbreak_pos = split_line(comp_line, comp_point)

        # _ARGCOMPLETE is set by the shell script to tell us where comp_words
        # should start, based on what we're completing.
        # 1: <script> [args]
        # 2: python <script> [args]
        # 3: python -m <module> [args]
        start = int(os.environ["_ARGCOMPLETE"]) - 1
        comp_words = comp_words[start:]

        if cword_prefix and cword_prefix[0] in self._parser.prefix_chars and "=" in cword_prefix:
            # Special case for when the current word is "--optional=PARTIAL_VALUE". Give the optional to the parser.
            comp_words.append(cword_prefix.split("=", 1)[0])

        debug("\nLINE: {!r}".format(comp_line),
              "\nPOINT: {!r}".format(comp_point),
              "\nPREQUOTE: {!r}".format(cword_prequote),
              "\nPREFIX: {!r}".format(cword_prefix),
              "\nSUFFIX: {!r}".format(cword_suffix),
              "\nWORDS:", comp_words)

        completions = self._get_completions(comp_words, cword_prefix, cword_prequote, last_wordbreak_pos)

        if dfs:
            display_completions = {key_part: value.replace(ifs, " ") if value else ""
                                   for key, value in self._display_completions.items()
                                   for key_part in key}
            completions = [dfs.join((key, display_completions.get(key) or "")) for key in completions]

        debug("\nReturning completions:", completions)
        output_stream.write(ifs.join(completions))
>       output_stream.flush()
E       OSError: [Errno 9] Bad file descriptor

argcomplete/__init__.py:242: OSError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/test/test.py", line 80, in run_completer
    completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/argcomplete/__init__.py", line 242, in __call__
    output_stream.flush()
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

self = <test.test.TestArgcomplete testMethod=test_action_activation_with_subparser>

    def test_action_activation_with_subparser(self):
        def make_parser():
            parser = ArgumentParser()
            parser.add_argument("name", nargs=2, choices=["a", "b", "c"])
            subparsers = parser.add_subparsers(title="subcommands", metavar="subcommand")
            subparser_build = subparsers.add_parser("build")
            subparser_build.add_argument("var", choices=["bus", "car"])
            subparser_build.add_argument("--profile", nargs=1)
            return parser

        expected_outputs = (
            ("prog ", ["a", "b", "c", "-h", "--help"]),
            ("prog b", ["b "]),
            ("prog b ", ["a", "b", "c", "-h", "--help"]),
            ("prog c b ", ["build", "-h", "--help"]),
            ("prog c b bu", ["build "]),
            ("prog c b build ", ["bus", "car", "--profile", "-h", "--help"]),
            ("prog c b build ca", ["car "]),
            ("prog c b build car ", ["--profile", "-h", "--help"]),
            ("prog build car ", ["-h", "--help"]),
            ("prog a build car ", ["-h", "--help"]),
        )

        for cmd, output in expected_outputs:
>           self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))

test/test.py:229:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <test.test.TestArgcomplete testMethod=test_action_activation_with_subparser>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59d61790>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
                completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
            if cm.exception.code != 0:
                raise Exception("Unexpected exit code %d" % cm.exception.code)
            t.seek(0)
>           return t.read().split(IFS)
E           OSError: [Errno 9] Bad file descriptor

test/test.py:84: OSError
____________________________________________________________________ TestArgcomplete.test_append_space _____________________________________________________________________

self = <test.test.TestArgcomplete testMethod=test_append_space>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59f40190>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
>               completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)

test/test.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def __call__(self, argument_parser, always_complete_options=True, exit_method=os._exit, output_stream=None,
                 exclude=None, validator=None, print_suppressed=False, append_space=None,
                 default_completer=FilesCompleter()):
        """
        :param argument_parser: The argument parser to autocomplete on
        :type argument_parser: :class:`argparse.ArgumentParser`
        :param always_complete_options:
            Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
            been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
            suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
            with no long variant will be suggested. If ``short``, short options and long options with no short variant
            will be suggested.
        :type always_complete_options: boolean or string
        :param exit_method:
            Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
            perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
        :type exit_method: callable
        :param exclude: List of strings representing options to be omitted from autocompletion
        :type exclude: iterable
        :param validator:
            Function to filter all completions through before returning (called with two string arguments, completion
            and prefix; return value is evaluated as a boolean)
        :type validator: callable
        :param print_suppressed:
            Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
        :type print_suppressed: boolean
        :param append_space:
            Whether to append a space to unique matches. The default is ``True``.
        :type append_space: boolean

        .. note::
            If you are not subclassing CompletionFinder to override its behaviors,
            use ``argcomplete.autocomplete()`` directly. It has the same signature as this method.

        Produces tab completions for ``argument_parser``. See module docs for more info.

        Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
        added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
        their execution is otherwise desirable.
        """
        self.__init__(argument_parser, always_complete_options=always_complete_options, exclude=exclude,
                      validator=validator, print_suppressed=print_suppressed, append_space=append_space,
                      default_completer=default_completer)

        if "_ARGCOMPLETE" not in os.environ:
            # not an argument completion invocation
            return

        global debug_stream
        try:
            debug_stream = os.fdopen(9, "w")
        except Exception:
            debug_stream = sys.stderr
        debug()

        if output_stream is None:
            filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME")
            if filename is not None:
                debug("Using output file {}".format(filename))
                output_stream = open(filename, "w")

        if output_stream is None:
            try:
                output_stream = os.fdopen(8, "w")
            except Exception:
                debug("Unable to open fd 8 for writing, quitting")
                exit_method(1)

        # print("", stream=debug_stream)
        # for v in "COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY _ARGCOMPLETE_COMP_WORDBREAKS COMP_WORDS".split():
        #     print(v, os.environ[v], stream=debug_stream)

        ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
        if len(ifs) != 1:
            debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
            exit_method(1)

        dfs = os.environ.get("_ARGCOMPLETE_DFS")
        if dfs and len(dfs) != 1:
            debug("Invalid value for DFS, quitting [{v}]".format(v=dfs))
            exit_method(1)

        comp_line = os.environ["COMP_LINE"]
        comp_point = int(os.environ["COMP_POINT"])

        cword_prequote, cword_prefix, cword_suffix, comp_words, last_wordbreak_pos = split_line(comp_line, comp_point)

        # _ARGCOMPLETE is set by the shell script to tell us where comp_words
        # should start, based on what we're completing.
        # 1: <script> [args]
        # 2: python <script> [args]
        # 3: python -m <module> [args]
        start = int(os.environ["_ARGCOMPLETE"]) - 1
        comp_words = comp_words[start:]

        if cword_prefix and cword_prefix[0] in self._parser.prefix_chars and "=" in cword_prefix:
            # Special case for when the current word is "--optional=PARTIAL_VALUE". Give the optional to the parser.
            comp_words.append(cword_prefix.split("=", 1)[0])

        debug("\nLINE: {!r}".format(comp_line),
              "\nPOINT: {!r}".format(comp_point),
              "\nPREQUOTE: {!r}".format(cword_prequote),
              "\nPREFIX: {!r}".format(cword_prefix),
              "\nSUFFIX: {!r}".format(cword_suffix),
              "\nWORDS:", comp_words)

        completions = self._get_completions(comp_words, cword_prefix, cword_prequote, last_wordbreak_pos)

        if dfs:
            display_completions = {key_part: value.replace(ifs, " ") if value else ""
                                   for key, value in self._display_completions.items()
                                   for key_part in key}
            completions = [dfs.join((key, display_completions.get(key) or "")) for key in completions]

        debug("\nReturning completions:", completions)
        output_stream.write(ifs.join(completions))
>       output_stream.flush()
E       OSError: [Errno 9] Bad file descriptor

argcomplete/__init__.py:242: OSError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/test/test.py", line 80, in run_completer
    completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/argcomplete/__init__.py", line 242, in __call__
    output_stream.flush()
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

self = <test.test.TestArgcomplete testMethod=test_append_space>

    def test_append_space(self):
        def make_parser():
            parser = ArgumentParser(add_help=False)
            parser.add_argument("foo", choices=["bar"])
            return parser

>       self.assertEqual(self.run_completer(make_parser(), "prog "), ["bar "])

test/test.py:736:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <test.test.TestArgcomplete testMethod=test_append_space>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59f40190>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
                completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
            if cm.exception.code != 0:
                raise Exception("Unexpected exit code %d" % cm.exception.code)
            t.seek(0)
>           return t.read().split(IFS)
E           OSError: [Errno 9] Bad file descriptor

test/test.py:84: OSError
__________________________________________________________________ TestArgcomplete.test_basic_completion ___________________________________________________________________

self = <test.test.TestArgcomplete testMethod=test_basic_completion>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59ce4b50>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
>               completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)

test/test.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def __call__(self, argument_parser, always_complete_options=True, exit_method=os._exit, output_stream=None,
                 exclude=None, validator=None, print_suppressed=False, append_space=None,
                 default_completer=FilesCompleter()):
        """
        :param argument_parser: The argument parser to autocomplete on
        :type argument_parser: :class:`argparse.ArgumentParser`
        :param always_complete_options:
            Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
            been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
            suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
            with no long variant will be suggested. If ``short``, short options and long options with no short variant
            will be suggested.
        :type always_complete_options: boolean or string
        :param exit_method:
            Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
            perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
        :type exit_method: callable
        :param exclude: List of strings representing options to be omitted from autocompletion
        :type exclude: iterable
        :param validator:
            Function to filter all completions through before returning (called with two string arguments, completion
            and prefix; return value is evaluated as a boolean)
        :type validator: callable
        :param print_suppressed:
            Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
        :type print_suppressed: boolean
        :param append_space:
            Whether to append a space to unique matches. The default is ``True``.
        :type append_space: boolean

        .. note::
            If you are not subclassing CompletionFinder to override its behaviors,
            use ``argcomplete.autocomplete()`` directly. It has the same signature as this method.

        Produces tab completions for ``argument_parser``. See module docs for more info.

        Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
        added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
        their execution is otherwise desirable.
        """
        self.__init__(argument_parser, always_complete_options=always_complete_options, exclude=exclude,
                      validator=validator, print_suppressed=print_suppressed, append_space=append_space,
                      default_completer=default_completer)

        if "_ARGCOMPLETE" not in os.environ:
            # not an argument completion invocation
            return

        global debug_stream
        try:
            debug_stream = os.fdopen(9, "w")
        except Exception:
            debug_stream = sys.stderr
        debug()

        if output_stream is None:
            filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME")
            if filename is not None:
                debug("Using output file {}".format(filename))
                output_stream = open(filename, "w")

        if output_stream is None:
            try:
                output_stream = os.fdopen(8, "w")
            except Exception:
                debug("Unable to open fd 8 for writing, quitting")
                exit_method(1)

        # print("", stream=debug_stream)
        # for v in "COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY _ARGCOMPLETE_COMP_WORDBREAKS COMP_WORDS".split():
        #     print(v, os.environ[v], stream=debug_stream)

        ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
        if len(ifs) != 1:
            debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
            exit_method(1)

        dfs = os.environ.get("_ARGCOMPLETE_DFS")
        if dfs and len(dfs) != 1:
            debug("Invalid value for DFS, quitting [{v}]".format(v=dfs))
            exit_method(1)

        comp_line = os.environ["COMP_LINE"]
        comp_point = int(os.environ["COMP_POINT"])

        cword_prequote, cword_prefix, cword_suffix, comp_words, last_wordbreak_pos = split_line(comp_line, comp_point)

        # _ARGCOMPLETE is set by the shell script to tell us where comp_words
        # should start, based on what we're completing.
        # 1: <script> [args]
        # 2: python <script> [args]
        # 3: python -m <module> [args]
        start = int(os.environ["_ARGCOMPLETE"]) - 1
        comp_words = comp_words[start:]

        if cword_prefix and cword_prefix[0] in self._parser.prefix_chars and "=" in cword_prefix:
            # Special case for when the current word is "--optional=PARTIAL_VALUE". Give the optional to the parser.
            comp_words.append(cword_prefix.split("=", 1)[0])

        debug("\nLINE: {!r}".format(comp_line),
              "\nPOINT: {!r}".format(comp_point),
              "\nPREQUOTE: {!r}".format(cword_prequote),
              "\nPREFIX: {!r}".format(cword_prefix),
              "\nSUFFIX: {!r}".format(cword_suffix),
              "\nWORDS:", comp_words)

        completions = self._get_completions(comp_words, cword_prefix, cword_prequote, last_wordbreak_pos)

        if dfs:
            display_completions = {key_part: value.replace(ifs, " ") if value else ""
                                   for key, value in self._display_completions.items()
                                   for key_part in key}
            completions = [dfs.join((key, display_completions.get(key) or "")) for key in completions]

        debug("\nReturning completions:", completions)
        output_stream.write(ifs.join(completions))
>       output_stream.flush()
E       OSError: [Errno 9] Bad file descriptor

argcomplete/__init__.py:242: OSError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/test/test.py", line 80, in run_completer
    completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/argcomplete/__init__.py", line 242, in __call__
    output_stream.flush()
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

self = <test.test.TestArgcomplete testMethod=test_basic_completion>

    def test_basic_completion(self):
        p = ArgumentParser()
        p.add_argument("--foo")
        p.add_argument("--bar")

>       completions = self.run_completer(p, "prog ")

test/test.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <test.test.TestArgcomplete testMethod=test_basic_completion>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59ce4b50>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
                completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
            if cm.exception.code != 0:
                raise Exception("Unexpected exit code %d" % cm.exception.code)
            t.seek(0)
>           return t.read().split(IFS)
E           OSError: [Errno 9] Bad file descriptor

test/test.py:84: OSError
_______________________________________________________________________ TestArgcomplete.test_choices _______________________________________________________________________

self = <test.test.TestArgcomplete testMethod=test_choices>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59d61850>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
>               completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)

test/test.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def __call__(self, argument_parser, always_complete_options=True, exit_method=os._exit, output_stream=None,
                 exclude=None, validator=None, print_suppressed=False, append_space=None,
                 default_completer=FilesCompleter()):
        """
        :param argument_parser: The argument parser to autocomplete on
        :type argument_parser: :class:`argparse.ArgumentParser`
        :param always_complete_options:
            Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
            been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
            suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
            with no long variant will be suggested. If ``short``, short options and long options with no short variant
            will be suggested.
        :type always_complete_options: boolean or string
        :param exit_method:
            Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
            perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
        :type exit_method: callable
        :param exclude: List of strings representing options to be omitted from autocompletion
        :type exclude: iterable
        :param validator:
            Function to filter all completions through before returning (called with two string arguments, completion
            and prefix; return value is evaluated as a boolean)
        :type validator: callable
        :param print_suppressed:
            Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
        :type print_suppressed: boolean
        :param append_space:
            Whether to append a space to unique matches. The default is ``True``.
        :type append_space: boolean

        .. note::
            If you are not subclassing CompletionFinder to override its behaviors,
            use ``argcomplete.autocomplete()`` directly. It has the same signature as this method.

        Produces tab completions for ``argument_parser``. See module docs for more info.

        Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
        added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
        their execution is otherwise desirable.
        """
        self.__init__(argument_parser, always_complete_options=always_complete_options, exclude=exclude,
                      validator=validator, print_suppressed=print_suppressed, append_space=append_space,
                      default_completer=default_completer)

        if "_ARGCOMPLETE" not in os.environ:
            # not an argument completion invocation
            return

        global debug_stream
        try:
            debug_stream = os.fdopen(9, "w")
        except Exception:
            debug_stream = sys.stderr
        debug()

        if output_stream is None:
            filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME")
            if filename is not None:
                debug("Using output file {}".format(filename))
                output_stream = open(filename, "w")

        if output_stream is None:
            try:
                output_stream = os.fdopen(8, "w")
            except Exception:
                debug("Unable to open fd 8 for writing, quitting")
                exit_method(1)

        # print("", stream=debug_stream)
        # for v in "COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY _ARGCOMPLETE_COMP_WORDBREAKS COMP_WORDS".split():
        #     print(v, os.environ[v], stream=debug_stream)

        ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
        if len(ifs) != 1:
            debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
            exit_method(1)

        dfs = os.environ.get("_ARGCOMPLETE_DFS")
        if dfs and len(dfs) != 1:
            debug("Invalid value for DFS, quitting [{v}]".format(v=dfs))
            exit_method(1)

        comp_line = os.environ["COMP_LINE"]
        comp_point = int(os.environ["COMP_POINT"])

        cword_prequote, cword_prefix, cword_suffix, comp_words, last_wordbreak_pos = split_line(comp_line, comp_point)

        # _ARGCOMPLETE is set by the shell script to tell us where comp_words
        # should start, based on what we're completing.
        # 1: <script> [args]
        # 2: python <script> [args]
        # 3: python -m <module> [args]
        start = int(os.environ["_ARGCOMPLETE"]) - 1
        comp_words = comp_words[start:]

        if cword_prefix and cword_prefix[0] in self._parser.prefix_chars and "=" in cword_prefix:
            # Special case for when the current word is "--optional=PARTIAL_VALUE". Give the optional to the parser.
            comp_words.append(cword_prefix.split("=", 1)[0])

        debug("\nLINE: {!r}".format(comp_line),
              "\nPOINT: {!r}".format(comp_point),
              "\nPREQUOTE: {!r}".format(cword_prequote),
              "\nPREFIX: {!r}".format(cword_prefix),
              "\nSUFFIX: {!r}".format(cword_suffix),
              "\nWORDS:", comp_words)

        completions = self._get_completions(comp_words, cword_prefix, cword_prequote, last_wordbreak_pos)

        if dfs:
            display_completions = {key_part: value.replace(ifs, " ") if value else ""
                                   for key, value in self._display_completions.items()
                                   for key_part in key}
            completions = [dfs.join((key, display_completions.get(key) or "")) for key in completions]

        debug("\nReturning completions:", completions)
        output_stream.write(ifs.join(completions))
>       output_stream.flush()
E       OSError: [Errno 9] Bad file descriptor

argcomplete/__init__.py:242: OSError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/test/test.py", line 80, in run_completer
    completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/argcomplete/__init__.py", line 242, in __call__
    output_stream.flush()
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

self = <test.test.TestArgcomplete testMethod=test_choices>

    def test_choices(self):
        def make_parser():
            parser = ArgumentParser()
            parser.add_argument("--ship", choices=["submarine", "speedboat"])
            return parser

        expected_outputs = (
            ("prog ", ["--ship", "-h", "--help"]),
            ("prog --shi", ["--ship "]),
            ("prog --ship ", ["submarine", "speedboat"]),
            ("prog --ship s", ["submarine", "speedboat"]),
            ("prog --ship su", ["submarine "]),
            ("prog --ship=", ["submarine", "speedboat"]),
            ("prog --ship=s", ["submarine", "speedboat"]),
            ("prog --ship=su", ["submarine "]),
        )

        for cmd, output in expected_outputs:
>           self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))

test/test.py:121:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <test.test.TestArgcomplete testMethod=test_choices>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog ', point = '5', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}, t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>
cm = <unittest.case._AssertRaisesContext object at 0x7f3e59d61850>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
                completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
            if cm.exception.code != 0:
                raise Exception("Unexpected exit code %d" % cm.exception.code)
            t.seek(0)
>           return t.read().split(IFS)
E           OSError: [Errno 9] Bad file descriptor

test/test.py:84: OSError
_____________________________________________________________________ TestArgcomplete.test_completers ______________________________________________________________________

self = <test.test.TestArgcomplete testMethod=test_completers>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog --url ', point = '11', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}
t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>, cm = <unittest.case._AssertRaisesContext object at 0x7f3e59c72e80>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
>               completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)

test/test.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def __call__(self, argument_parser, always_complete_options=True, exit_method=os._exit, output_stream=None,
                 exclude=None, validator=None, print_suppressed=False, append_space=None,
                 default_completer=FilesCompleter()):
        """
        :param argument_parser: The argument parser to autocomplete on
        :type argument_parser: :class:`argparse.ArgumentParser`
        :param always_complete_options:
            Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
            been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
            suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
            with no long variant will be suggested. If ``short``, short options and long options with no short variant
            will be suggested.
        :type always_complete_options: boolean or string
        :param exit_method:
            Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
            perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
        :type exit_method: callable
        :param exclude: List of strings representing options to be omitted from autocompletion
        :type exclude: iterable
        :param validator:
            Function to filter all completions through before returning (called with two string arguments, completion
            and prefix; return value is evaluated as a boolean)
        :type validator: callable
        :param print_suppressed:
            Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
        :type print_suppressed: boolean
        :param append_space:
            Whether to append a space to unique matches. The default is ``True``.
        :type append_space: boolean

        .. note::
            If you are not subclassing CompletionFinder to override its behaviors,
            use ``argcomplete.autocomplete()`` directly. It has the same signature as this method.

        Produces tab completions for ``argument_parser``. See module docs for more info.

        Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
        added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
        their execution is otherwise desirable.
        """
        self.__init__(argument_parser, always_complete_options=always_complete_options, exclude=exclude,
                      validator=validator, print_suppressed=print_suppressed, append_space=append_space,
                      default_completer=default_completer)

        if "_ARGCOMPLETE" not in os.environ:
            # not an argument completion invocation
            return

        global debug_stream
        try:
            debug_stream = os.fdopen(9, "w")
        except Exception:
            debug_stream = sys.stderr
        debug()

        if output_stream is None:
            filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME")
            if filename is not None:
                debug("Using output file {}".format(filename))
                output_stream = open(filename, "w")

        if output_stream is None:
            try:
                output_stream = os.fdopen(8, "w")
            except Exception:
                debug("Unable to open fd 8 for writing, quitting")
                exit_method(1)

        # print("", stream=debug_stream)
        # for v in "COMP_CWORD COMP_LINE COMP_POINT COMP_TYPE COMP_KEY _ARGCOMPLETE_COMP_WORDBREAKS COMP_WORDS".split():
        #     print(v, os.environ[v], stream=debug_stream)

        ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
        if len(ifs) != 1:
            debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
            exit_method(1)

        dfs = os.environ.get("_ARGCOMPLETE_DFS")
        if dfs and len(dfs) != 1:
            debug("Invalid value for DFS, quitting [{v}]".format(v=dfs))
            exit_method(1)

        comp_line = os.environ["COMP_LINE"]
        comp_point = int(os.environ["COMP_POINT"])

        cword_prequote, cword_prefix, cword_suffix, comp_words, last_wordbreak_pos = split_line(comp_line, comp_point)

        # _ARGCOMPLETE is set by the shell script to tell us where comp_words
        # should start, based on what we're completing.
        # 1: <script> [args]
        # 2: python <script> [args]
        # 3: python -m <module> [args]
        start = int(os.environ["_ARGCOMPLETE"]) - 1
        comp_words = comp_words[start:]

        if cword_prefix and cword_prefix[0] in self._parser.prefix_chars and "=" in cword_prefix:
            # Special case for when the current word is "--optional=PARTIAL_VALUE". Give the optional to the parser.
            comp_words.append(cword_prefix.split("=", 1)[0])

        debug("\nLINE: {!r}".format(comp_line),
              "\nPOINT: {!r}".format(comp_point),
              "\nPREQUOTE: {!r}".format(cword_prequote),
              "\nPREFIX: {!r}".format(cword_prefix),
              "\nSUFFIX: {!r}".format(cword_suffix),
              "\nWORDS:", comp_words)

        completions = self._get_completions(comp_words, cword_prefix, cword_prequote, last_wordbreak_pos)

        if dfs:
            display_completions = {key_part: value.replace(ifs, " ") if value else ""
                                   for key, value in self._display_completions.items()
                                   for key_part in key}
            completions = [dfs.join((key, display_completions.get(key) or "")) for key in completions]

        debug("\nReturning completions:", completions)
        output_stream.write(ifs.join(completions))
>       output_stream.flush()
E       OSError: [Errno 9] Bad file descriptor

argcomplete/__init__.py:242: OSError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/test/test.py", line 80, in run_completer
    completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
  File "/home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.0/argcomplete/__init__.py", line 242, in __call__
    output_stream.flush()
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

self = <test.test.TestArgcomplete testMethod=test_completers>

    def test_completers(self):
        def c_url(prefix, parsed_args, **kwargs):
            return ["http://url1", "http://url2"]

        def make_parser():
            parser = ArgumentParser()
            parser.add_argument("--url").completer = c_url
            parser.add_argument("--email", nargs=3, choices=["a@b.c", "a@b.d", "ab@c.d", "bcd@e.f", "bce@f.g"])
            return parser

        expected_outputs = (
            ("prog --url ", ["http://url1", "http://url2"]),
            ("prog --url \"", ['http://url1', 'http://url2']),
            ("prog --url \"http://url1\" --email ", ["a@b.c", "a@b.d", "ab@c.d", "bcd@e.f", "bce@f.g"]),
            ("prog --url \"http://url1\" --email a", ["a@b.c", "a@b.d", "ab@c.d"]),
            ("prog --url \"http://url1\" --email \"a@", ['a@b.c', 'a@b.d']),
            ("prog --url \"http://url1\" --email \"a@b.c\" \"a@b.d\" \"a@", ['a@b.c', 'a@b.d']),
            ("prog --url \"http://url1\" --email \"a@b.c\" \"a@b.d\" \"ab@c.d\" ",
             ["--url", "--email", "-h", "--help"]),
        )

        for cmd, output in expected_outputs:
>           self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))

test/test.py:253:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <test.test.TestArgcomplete testMethod=test_completers>
parser = MonkeyPatchedIntrospectiveArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
command = 'prog --url ', point = '11', completer = <argcomplete.CompletionFinder object at 0x7f3e5a6c11f0>, kwargs = {}
t = <_io.TextIOWrapper name=9 mode='w+' encoding='UTF-8'>, cm = <unittest.case._AssertRaisesContext object at 0x7f3e59c72e80>

    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        if point is None:
            point = str(len(command))
        with TemporaryFile(mode="w+") as t:
            os.environ["COMP_LINE"] = command
            os.environ["COMP_POINT"] = point
            with self.assertRaises(SystemExit) as cm:
                completer(parser, output_stream=t, exit_method=sys.exit, **kwargs)
            if cm.exception.code != 0:
                raise Exception("Unexpected exit code %d" % cm.exception.code)
            t.seek(0)
>           return t.read().split(IFS)
E           OSError: [Errno 9] Bad file descriptor

test/test.py:84: OSError
__________________________________________________________________ TestArgcomplete.test_custom_validator ___________________________________________________________________

[..]

___________________________________________________________ TestBashGlobal.test_parse_special_characters_dollar ____________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_parse_special_characters_dollar>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
__________________________________________________________________ TestBashGlobal.test_partial_completion __________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_partial_completion>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
__________________________________________________________________ TestBashGlobal.test_python_completion ___________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_python_completion>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
______________________________________________________________ TestBashGlobal.test_python_filename_completion ______________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_python_filename_completion>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
____________________________________________________________________ TestBashGlobal.test_python_module _____________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_python_module>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
________________________________________________________________ TestBashGlobal.test_python_not_executable _________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_python_not_executable>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
_____________________________________________________________________ TestBashGlobal.test_quoted_exact _____________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_quoted_exact>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
_____________________________________________________________________ TestBashGlobal.test_quoted_space _____________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_quoted_space>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
________________________________________________________________________ TestBashGlobal.test_quotes ________________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_quotes>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
__________________________________________________________________ TestBashGlobal.test_simple_completion ___________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_simple_completion>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
_______________________________________________________________ TestBashGlobal.test_single_quoted_completion _______________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_single_quoted_completion>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
____________________________________________________________ TestBashGlobal.test_single_quotes_in_double_quotes ____________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_single_quotes_in_double_quotes>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
____________________________________________________________ TestBashGlobal.test_single_quotes_in_single_quotes ____________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_single_quotes_in_single_quotes>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
__________________________________________________________________ TestBashGlobal.test_special_characters __________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_special_characters>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
___________________________________________________________ TestBashGlobal.test_special_characters_double_quoted ___________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_special_characters_double_quoted>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
___________________________________________________________ TestBashGlobal.test_special_characters_single_quoted ___________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_special_characters_single_quoted>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
______________________________________________________________________ TestBashGlobal.test_temp_file _______________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_temp_file>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
____________________________________________________________________ TestBashGlobal.test_unquoted_space ____________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_unquoted_space>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
___________________________________________________________________ TestBashGlobal.test_wordbreak_chars ____________________________________________________________________

self = <test.test.TestBashGlobal testMethod=test_wordbreak_chars>

    def setUp(self):
        sh = pexpect.replwrap.bash()
        path = ':'.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH'])
        sh.run_command('export PATH={0}'.format(path))
        sh.run_command('export PYTHONPATH={0}'.format(BASE_DIR))
        # Disable the "python" module provided by bash-completion
        sh.run_command('complete -r python3')
        output = sh.run_command(self.install_cmd)
>       self.assertEqual(output, '')
E       AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
-       -

test/test.py:1202: AssertionError
_________________________________________________________________________ TestTcsh.test_comp_point _________________________________________________________________________

self = <test.test.TestTcsh testMethod=test_comp_point>

    def test_comp_point(self):
        # Use environment variable to change how prog behaves
>       self.assertEqual(self.sh.run_command('export POINT=1'), '')
E       AssertionError: 'export: Command not found.\r\n' != ''
E       - export: Command not found.

test/test.py:1174: AssertionError
_________________________________________________________________________ TestFish.test_comp_point _________________________________________________________________________

self = <test.test.TestFish testMethod=test_comp_point>

    def test_comp_point(self):
        # Use environment variable to change how prog behaves
        self.assertEqual(self.sh.run_command('export POINT=1'), '')
>       self.assertEqual(self.sh.run_command('prog point hi\t'), '13\r\n')
E       AssertionError: 'hi\r\n' != '13\r\n'
E       - hi
E       + 13

test/test.py:1175: AssertionError
========================================================================= short test summary info ==========================================================================
SKIPPED [2] test/test.py:1081: skip
XFAIL test/test.py::TestSplitLine::test_escaped_special_in_double_quotes
  reason:
XFAIL test/test.py::TestTcsh::test_continuation
  reason:
XFAIL test/test.py::TestTcsh::test_parse_special_characters
  reason:
XFAIL test/test.py::TestTcsh::test_parse_special_characters_dollar
  reason:
XFAIL test/test.py::TestTcsh::test_quoted_space
  reason:
XFAIL test/test.py::TestTcsh::test_unquoted_space
  reason:
XFAIL test/test.py::TestFish::test_parse_special_characters
  reason:
FAILED test/test.py::TestArgcomplete::test_action_activation - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_action_activation_with_subparser - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_append_space - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_basic_completion - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_choices - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_completers - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_custom_validator - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_default_completer - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_different_validators - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_escape_special_chars - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_exclusive - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_exclusive_class - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_filescompleter_filetype_integration - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_mixed_optional_positional - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_nargs_one_or_more - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_nargs_optional - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_nargs_zero_or_more - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_non_ascii - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_non_str_choices - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_option_help - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_optional_long_short_filtering - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_optional_nargs - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_positional_remainder - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_skipped_completer - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_subparser_completers - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_subparsers - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_suppress_args - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestArgcomplete::test_suppress_completer - OSError: [Errno 9] Bad file descriptor
FAILED test/test.py::TestBash::test_comp_point - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_completion_environment - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_continuation - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_debug_output - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_double_quoted_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_exclamation_in_double_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_nounset - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_one_space_after_exact - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_parse_special_characters - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_parse_special_characters_dollar - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_partial_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_quoted_exact - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_quoted_space - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_simple_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_single_quoted_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_single_quotes_in_double_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_single_quotes_in_single_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_special_characters - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_special_characters_double_quoted - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_special_characters_single_quoted - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_temp_file - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_unquoted_space - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBash::test_wordbreak_chars - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_comp_point - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_completion_environment - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_console_script_module - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_console_script_module_wheel - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_console_script_package - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_console_script_package_wheel - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_continuation - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_debug_output - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_double_quoted_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_exclamation_in_double_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_nounset - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_one_space_after_exact - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_parse_special_characters - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_parse_special_characters_dollar - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_partial_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_python_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_python_filename_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_python_module - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_python_not_executable - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_quoted_exact - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_quoted_space - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_simple_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_single_quoted_completion - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_single_quotes_in_double_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_single_quotes_in_single_quotes - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_special_characters - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_special_characters_double_quoted - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_special_characters_single_quoted - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_temp_file - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_unquoted_space - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestBashGlobal::test_wordbreak_chars - AssertionError: '\x1b[?2004l\r\x1b[?2004h' != ''
FAILED test/test.py::TestTcsh::test_comp_point - AssertionError: 'export: Command not found.\r\n' != ''
FAILED test/test.py::TestFish::test_comp_point - AssertionError: 'hi\r\n' != '13\r\n'
====================================================== 86 failed, 53 passed, 2 skipped, 7 xfailed in 89.34s (0:01:29) ======================================================

The same is when I'm runnnimg directly python3 test/test.py.

@kislyuk
Copy link
Owner

kislyuk commented Jan 4, 2022

This is the same issue as #337. Please use the workaround described there.

@kislyuk kislyuk closed this as completed Jan 4, 2022
@kislyuk
Copy link
Owner

kislyuk commented Jan 4, 2022

See also #354 and the workaround I described there when you previously filed the issue.

@kloczek
Copy link
Author

kloczek commented Mar 5, 2023

Just tested all comits from master and I see still two units failing

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-argcomplete-2.0.5-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-argcomplete-2.0.5-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' test/test.py
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/argcomplete-2.0.5, configfile: pyproject.toml
collected 148 items

test/test.py ...................................usage: pytest [-h] --foo FOO {bar}
pytest: error: too few arguments
usage: pytest [-h] --foo FOO {bar}
pytest: error: argument --foo is required
...usage: pytest foo [-h] {bar}
pytest foo: error: too few arguments
..x..............x...x.......................x...x..................F.x..xx..x........x.F....xs.......s.......

========================================================================================= FAILURES ==========================================================================================
_________________________________________________________________________________ TestTcsh.test_comp_point __________________________________________________________________________________

self = <test.test.TestTcsh testMethod=test_comp_point>

    def test_comp_point(self):
        # Use environment variable to change how prog behaves
>       self.assertEqual(self.sh.run_command("export POINT=1"), "")
E       AssertionError: 'export: Command not found.\r\n' != ''
E       - export: Command not found.

test/test.py:1185: AssertionError
_________________________________________________________________________________ TestFish.test_comp_point __________________________________________________________________________________

self = <test.test.TestFish testMethod=test_comp_point>

    def test_comp_point(self):
        # Use environment variable to change how prog behaves
        self.assertEqual(self.sh.run_command("export POINT=1"), "")
>       self.assertEqual(self.sh.run_command("prog point hi\t"), "13\r\n")
E       AssertionError: 'hi\r\n' != '13\r\n'
E       - hi
E       + 13

test/test.py:1186: AssertionError
================================================================================== short test summary info ==================================================================================
SKIPPED [2] test/test.py:1091: skip
XFAIL test/test.py::TestSplitLine::test_escaped_special_in_double_quotes - reason:
XFAIL test/test.py::TestBash::test_exclamation_in_double_quotes - reason:
XFAIL test/test.py::TestBash::test_parse_special_characters_dollar - reason:
XFAIL test/test.py::TestBashGlobal::test_exclamation_in_double_quotes - reason:
XFAIL test/test.py::TestBashGlobal::test_parse_special_characters_dollar - reason:
XFAIL test/test.py::TestTcsh::test_continuation - reason:
XFAIL test/test.py::TestTcsh::test_parse_special_characters - reason:
XFAIL test/test.py::TestTcsh::test_parse_special_characters_dollar - reason:
XFAIL test/test.py::TestTcsh::test_quoted_space - reason:
XFAIL test/test.py::TestTcsh::test_unquoted_space - reason:
XFAIL test/test.py::TestFish::test_parse_special_characters - reason:
FAILED test/test.py::TestTcsh::test_comp_point - AssertionError: 'export: Command not found.\r\n' != ''
FAILED test/test.py::TestFish::test_comp_point - AssertionError: 'hi\r\n' != '13\r\n'
============================================================= 2 failed, 133 passed, 2 skipped, 11 xfailed in 124.55s (0:02:04) ==============================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants