MatthewFlamm / pytest-homeassistant-custom-component

Package to automatically extract testing plugins from Home Assistant for custom component testing
MIT License
67 stars 10 forks source link

AttributeError: 'async_generator' object has no attribute 'data' #168

Closed iprak closed 1 year ago

iprak commented 1 year ago

I am not sure if this is entirely due to the new release but maybe you have some idea. I am using pytest-homeassistant-custom-component==0.13.55 and homeassistant==2023.9.1

My sample test is this

def test_form(hass, enable_custom_integrations):
    """Test we get the form."""
    hass.config.latitude = 18.10

which gives

hass = <async_generator object hass at 0x7f941a187220>

    @pytest.fixture
    def enable_custom_integrations(hass: HomeAssistant) -> None:
        """Enable custom integrations defined in the test dir."""
>       hass.data.pop(loader.DATA_CUSTOM_COMPONENTS)
E       AttributeError: 'async_generator' object has no attribute 'data'

/usr/local/lib/python3.11/site-packages/pytest_homeassistant_custom_component/plugins.py:1140: AttributeError

I get the same results if I follow your pattern of defining an autouse fixture.

@pytest.fixture(autouse=True)
def auto_enable_custom_integrations(enable_custom_integrations):
    yield

Thanks

MatthewFlamm commented 1 year ago

158 and #161 might help you