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

test__itch_tools__tail_itch__ctrl_c test fails in CI pipeline #21

Open
SamDanielThangarajan opened this issue Oct 5, 2024 · 1 comment

Comments

@SamDanielThangarajan
Copy link
Collaborator

Describe the bug
When run in CI job, test__itch_tools__tail_itch__ctrl_c fails

To Reproduce
Steps to reproduce the behavior:

TC fails with following error

=================================== FAILURES ===================================
_____________________ test__itch_tools__tail_itch__ctrl_c ______________________

mock_server_session = (58235, MockServerSession(connected=False, port=0, actions=[], transport=None))
load_itch_tools = <function load_itch_tools.<locals>.generator at 0x7f1ed9935d00>

    async def test__itch_tools__tail_itch__ctrl_c(mock_server_session, load_itch_tools):
>       definitions, tools = load_itch_tools('test__itch_tools__tail_itch__ctrl_c')

tests/test_itch_tools.py:139: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_itch_tools.py:41: in generator
    definitions = load_itch_definitions(app_name)
tests/test_itch_tools.py:24: in generator
    generated_files = codegen_invoker(
tests/conftest.py:49: in generator
    result = runner.invoke(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <click.testing.CliRunner object at 0x7f1ed9a220d0>
cli = <Command generate>
args = ['--spec-file', 'spec.xml', '--app-name', 'test__itch_tools__tail_itch__ctrl_c', '--op-dir', 'output', ...]
input = None, env = None, catch_exceptions = True, color = False, extra = {}
exc_info = (<class 'SystemExit'>, SystemExit(0), <traceback object at 0x7f1ed9f1c740>)
outstreams = (<_io.BytesIO object at 0x7f1ed99cd850>, None), return_value = None
exception = None, exit_code = 0, prog_name = 'generate'

    def invoke(
        self,
        cli: "BaseCommand",
        args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
        input: t.Optional[t.Union[str, bytes, t.IO[t.Any]]] = None,
        env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
        catch_exceptions: bool = True,
        color: bool = False,
        **extra: t.Any,
    ) -> Result:
        """Invokes a command in an isolated environment.  The arguments are
        forwarded directly to the command line script, the `extra` keyword
        arguments are passed to the :meth:`~clickpkg.Command.main` function of
        the command.
    
        This returns a :class:`Result` object.
    
        :param cli: the command to invoke
        :param args: the arguments to invoke. It may be given as an iterable
                     or a string. When given as string it will be interpreted
                     as a Unix shell command. More details at
                     :func:`shlex.split`.
        :param input: the input data for `sys.stdin`.
        :param env: the environment overrides.
        :param catch_exceptions: Whether to catch any other exceptions than
                                 ``SystemExit``.
        :param extra: the keyword arguments to pass to :meth:`main`.
        :param color: whether the output should contain color codes. The
                      application can still override this explicitly.
    
        .. versionchanged:: 8.0
            The result object has the ``return_value`` attribute with
            the value returned from the invoked command.
    
        .. versionchanged:: 4.0
            Added the ``color`` parameter.
    
        .. versionchanged:: 3.0
            Added the ``catch_exceptions`` parameter.
    
        .. versionchanged:: 3.0
            The result object has the ``exc_info`` attribute with the
            traceback if available.
        """
        exc_info = None
        with self.isolation(input=input, env=env, color=color) as outstreams:
            return_value = None
            exception: t.Optional[BaseException] = None
            exit_code = 0
    
            if isinstance(args, str):
                args = shlex.split(args)
    
            try:
                prog_name = extra.pop("prog_name")
            except KeyError:
                prog_name = self.get_default_prog_name(cli)
    
            try:
                return_value = cli.main(args=args or (), prog_name=prog_name, **extra)
            except SystemExit as e:
                exc_info = sys.exc_info()
                e_code = t.cast(t.Optional[t.Union[int, t.Any]], e.code)
    
                if e_code is None:
                    e_code = 0
    
                if e_code != 0:
                    exception = e
    
                if not isinstance(e_code, int):
                    sys.stdout.write(str(e_code))
                    sys.stdout.write("\n")
                    e_code = 1
    
                exit_code = e_code
    
            except Exception as e:
                if not catch_exceptions:
                    raise
                exception = e
                exit_code = 1
                exc_info = sys.exc_info()
            finally:
                sys.stdout.flush()
>               stdout = outstreams[0].getvalue()
E               ValueError: I/O operation on closed file.

.tox/test/lib/python3.11/site-packages/click/testing.py:434: ValueError
------------------------------ Captured log setup ------------------------------
asyncio             : Using selector: EpollSelector
----------------------------- Captured stdout call -----------------------------
Generated: output/itch_test__itch_tools__tail_itch__ctrl_c.py
------------------------------ Captured log call -------------------------------
asyncio             : Task exception was never retrieved
future: <Task finished name='Task-1000' coro=<tail_itch() done, defined at /home/runner/work/nasdaq-protocols/nasdaq-protocols/src/nasdaq_protocols/itch/tools.py:5> exception=gaierror(-5, 'No address associated with hostname')>
Traceback (most recent call last):
  File "/home/runner/work/nasdaq-protocols/nasdaq-protocols/src/nasdaq_protocols/itch/tools.py", line 26, in tail_itch
    itch_session = await itch_connector(
                   ^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 46, in connect_async
  File "/home/runner/work/nasdaq-protocols/nasdaq-protocols/src/nasdaq_protocols/itch/__init__.py", line 53, in connect_async
    soup_session = await soup.connect_async(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/nasdaq-protocols/nasdaq-protocols/src/nasdaq_protocols/soup/__init__.py", line 111, in connect_async
    _, soup_session = await loop.create_connection(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/asyncio/base_events.py", line 1046, in create_connection
    infos = await self._ensure_resolved(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/asyncio/base_events.py", line 1420, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/asyncio/base_events.py", line 868, in getaddrinfo
    return await self.run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/socket.py", line 974, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -5] No address associated with hostname

Currently, the test is marked as x-failed, due to this issue.

Expected behavior
Test case should not fail.

@SamDanielThangarajan
Copy link
Collaborator Author

disabling capsys might solve this issue. Potential fix coming in #26

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

1 participant