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

Pytest silent fail #117296

Open
dgomes opened this issue May 12, 2024 · 0 comments
Open

Pytest silent fail #117296

dgomes opened this issue May 12, 2024 · 0 comments
Assignees

Comments

@dgomes
Copy link
Contributor

dgomes commented May 12, 2024

The problem

Pytest is failing after running all the tests.

What version of Home Assistant Core has the issue?

dev

What was the last working version of Home Assistant Core?

before #117264

What type of installation are you running?

Home Assistant Core

Integration causing the issue

v2c

Link to integration documentation on our website

No response

Diagnostics information

No need to setup anything.

Just run pytest for integration v2c: pytest ./tests/components/v2c/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Test session starts (platform: darwin, Python 3.12.2, pytest 8.2.0, pytest-sugar 1.0.0)
cachedir: .pytest_cache
rootdir: /Users/dgomes/Projects/home-assistant
configfile: pyproject.toml
plugins: syrupy-4.6.1, cov-5.0.0, github-actions-annotate-failures-0.2.0, respx-0.21.1, pytest_freezer-0.4.8, sugar-1.0.0, socket-0.7.0, anyio-4.3.0, unordered-0.6.0, picked-0.5.0, aiohttp-1.0.5, timeout-2.3.1, asyncio-0.23.6, test-groups-1.0.3, xdist-3.6.1, requests-mock-1.12.1
asyncio: mode=Mode.AUTO
collected 4 items                                                                                                                                                                                   

 tests/components/v2c/test_config_flow.py::test_full_flow ✓                                                                                                                            25% ██▌       
 tests/components/v2c/test_config_flow.py::test_form_cannot_connect[TrydanError-cannot_connect] ✓                                                                                      50% █████     
 tests/components/v2c/test_config_flow.py::test_form_cannot_connect[Exception-unknown] ✓                                                                                               75% ███████▌  
 tests/components/v2c/test_sensor.py::test_sensor ✓                                                                                                                                   100% ██████████

---------- coverage: platform darwin, python 3.12.2-final-0 ----------
Name                                          Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------
homeassistant/components/v2c/config_flow.py      30      0   100%
homeassistant/components/v2c/const.py             1      0   100%
homeassistant/components/v2c/sensor.py           32      0   100%
---------------------------------------------------------------------------
TOTAL                                            63      0   100%

-------------------------------------------------------------------------------------- snapshot report summary --------------------------------------------------------------------------------------
14 snapshots passed.

Results (0.55s):
       4 passed
--- Logging error ---
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py", line 1163, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1869, in call_exception_handler
    ctx.run(self._exception_handler, self, context)
  File "/Users/dgomes/Projects/home-assistant/tests/conftest.py", line 550, in exc_handle
    orig_exception_handler(loop, context)
  File "/Users/dgomes/Projects/home-assistant/homeassistant/runner.py", line 139, in _async_loop_exception_handler
    logger.error(
Message: 'Error doing job: %s: %s'
Arguments: ('Task exception was never retrieved', '  File "/Users/dgomes/Projects/home-assistant/venv/bin/pytest", line 8, in <module>\n    sys.exit(console_main())\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 206, in console_main\n    code = main()\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 178, in main\n    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__\n    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec\n    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall\n    res = hook_impl.function(*args)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 332, in pytest_cmdline_main\n    return wrap_session(config, _main)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 285, in wrap_session\n    session.exitstatus = doit(config, session) or 0\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 339, in _main\n    config.hook.pytest_runtestloop(session=session)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__\n    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec\n    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall\n    res = hook_impl.function(*args)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 364, in pytest_runtestloop\n    item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__\n    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec\n    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall\n    res = hook_impl.function(*args)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 116, in pytest_runtest_protocol\n    runtestprotocol(item, nextitem=nextitem)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 136, in runtestprotocol\n    reports.append(call_and_report(item, "teardown", log, nextitem=nextitem))\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 240, in call_and_report\n    call = CallInfo.from_call(\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 341, in from_call\n    result: Optional[TResult] = func()\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 241, in <lambda>\n    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__\n    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec\n    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall\n    res = hook_impl.function(*args)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 188, in pytest_runtest_teardown\n    item.session._setupstate.teardown_exact(nextitem)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 544, in teardown_exact\n    fin()\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/fixtures.py", line 1009, in finish\n    fin()\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pytest_asyncio/plugin.py", line 342, in finalizer\n    event_loop.run_until_complete(async_finalizer())\n  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete\n    self.run_forever()\n  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 639, in run_forever\n    self._run_once()\n  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1977, in _run_once\n    handle._run()\n  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py", line 88, in _run\n    self._context.run(self._callback, *self._args)\n  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pytest_asyncio/plugin.py", line 334, in async_finalizer\n    await gen_obj.__anext__()\n  File "/Users/dgomes/Projects/home-assistant/tests/conftest.py", line 575, in hass\n    await hass.async_stop(force=True)\n  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 1165, in async_stop\n    self.bus.async_fire_internal(EVENT_HOMEASSISTANT_FINAL_WRITE)\n  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 1559, in async_fire_internal\n    self._hass.async_run_hass_job(job, event)\n  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 936, in async_run_hass_job\n    hassjob.target(*args)\n  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 1416, in __call__\n    self.hass.async_run_hass_job(self.listener_job, event)\n  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 939, in async_run_hass_job\n    return self._async_add_hass_job(hassjob, *args, background=background)\n  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 748, in _async_add_hass_job\n    task = create_eager_task(\n  File "/Users/dgomes/Projects/home-assistant/homeassistant/util/async_.py", line 40, in create_eager_task\n    return Task(coro, loop=loop, name=name, eager_start=True)\n')

Additional information

Unrolling the logger argument:

File "/Users/dgomes/Projects/home-assistant/venv/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 206, in console_main
    code = main()
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 178, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 332, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 285, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 339, in _main
    config.hook.pytest_runtestloop(session=session)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/main.py", line 364, in pytest_runtestloop
    item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 116, in pytest_runtest_protocol
    runtestprotocol(item, nextitem=nextitem)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 136, in runtestprotocol
    reports.append(call_and_report(item, "teardown", log, nextitem=nextitem))
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 240, in call_and_report
    call = CallInfo.from_call(
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 341, in from_call
    result: Optional[TResult] = func()
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 241, in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 188, in pytest_runtest_teardown
    item.session._setupstate.teardown_exact(nextitem)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/runner.py", line 544, in teardown_exact
    fin()
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/_pytest/fixtures.py", line 1009, in finish
    fin()
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pytest_asyncio/plugin.py", line 342, in finalizer
    event_loop.run_until_complete(async_finalizer())
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
    self.run_forever()
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
    self._run_once()
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1977, in _run_once
    handle._run()
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/dgomes/Projects/home-assistant/venv/lib/python3.12/site-packages/pytest_asyncio/plugin.py", line 334, in async_finalizer
    await gen_obj.__anext__()
  File "/Users/dgomes/Projects/home-assistant/tests/conftest.py", line 574, in hass
    await hass.async_stop(force=True)
  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 1165, in async_stop
    self.bus.async_fire_internal(EVENT_HOMEASSISTANT_FINAL_WRITE)
  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 1559, in async_fire_internal
    self._hass.async_run_hass_job(job, event)
  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 936, in async_run_hass_job
    hassjob.target(*args)
  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 1416, in __call__
    self.hass.async_run_hass_job(self.listener_job, event)
  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 939, in async_run_hass_job
    return self._async_add_hass_job(hassjob, *args, background=background)
  File "/Users/dgomes/Projects/home-assistant/homeassistant/core.py", line 748, in _async_add_hass_job
    task = create_eager_task(
  File "/Users/dgomes/Projects/home-assistant/homeassistant/util/async_.py", line 40, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
'

dgomes added a commit to dgomes/home-assistant that referenced this issue May 12, 2024
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