I’m trying to create automated tests for a custom component (V-Zug). The goal is to run them from vscode in a devcontainer. So far, I have successfully managed to create tests that are device API related.
My next goal is to have Home Assistant related ones, e.g., create a test_config_flow.py
as in GitHub - MatthewFlamm/pytest-homeassistant-custom-component: Package to automatically extract testing plugins from Home Assistant for custom component testing
async def test_xyz(hass: HomeAssistant):
....
$ pytest test_config_flow.py
...
fixture 'hass' not found
...
Pretty much all tests I saw, require ‘hass’ as input. Therefore, I seem to miss a concept or two. Despite reading core documentation (like Testing your code | Home Assistant Developer Docs) and pulling different repositories, I’ve not found any example which allowed me to properly initialize the preconditions.
I’ve tried a simple one, just to be greeted with the next error.
@pytest.fixture
def hass():
return HomeAssistant(os.path.join(os.getenv("PROJECT_ROOT"), "config"))
It does not make a difference, whether HomeAssistant is running in the background or not. Am I supposed to trigger these test from the UI?
Any suggestion is welcome.