Closed craigbarratt closed 1 year ago
Oops, duplicate of #158. Let me review that for the solution.
Confirmed that pytest --asyncio-mode=auto
solves it for me too. I would still like to understand why that is necessary - why does the 086baf1 commit now mean that --asyncio-mode=auto
is required? I believe I have the right decorators on all my async test functions.
As with anything async, it is a bit mysterious (at least to me) since it is one more layer obfuscated. It starts around #141 when pytest-asyncio version was bumped, and then I think there were later changes in the core fixtures that caused this error to pop up as the symptom.
I'm not sure about this, but pytest-asyncio might have different behavior for fixtures depending on the mode (or decorations on the fixtures themselves). Note that downstream users do not mark the fixtures in this package, which are more or less directly extracted from homeassistant/core. I believe homeassistant/core also uses the auto mode in configuration. My thinking is that you actually need to use the auto mode to get the async fixtures to behave properly even if the fixtures come from a different package. I'm not sure there is an easy way to mark them here.
Thanks for the explanation. I definitely don't understand any of the test harness magic (so many layers!), but using pytest --asyncio-mode=auto
seems like a decent solution.
Thanks for your work on pytest-homeassistant-custom-component
, without which pyscript
would have no tests.
pyscript is a custom integration and uses pytest-homeassistant-custom-component for all its tests.
Starting with 0.13.24 (which upgrades to
homeassistant==2023.5.0b4
and I'm using python3.11.3
) all my tests get this error:The 086baf1 commit appears to have changed how the
hass
object is created.Here's how a typical test is defined:
What am I missing to make my tests work again?