"""The tests for the Template Weather platform."""
from homeassistant.components.weather import (
    ATTR_WEATHER_ATTRIBUTION,
    ATTR_WEATHER_HUMIDITY,
    ATTR_WEATHER_OZONE,
    ATTR_WEATHER_PRESSURE,
    ATTR_WEATHER_TEMPERATURE,
    ATTR_WEATHER_VISIBILITY,
    ATTR_WEATHER_WIND_BEARING,
    ATTR_WEATHER_WIND_SPEED,
    DOMAIN,
)
from homeassistant.setup import async_setup_component


async def test_template_state_text(hass):
    """Test the state text of a template."""
    await async_setup_component(
        hass,
        DOMAIN,
        {
            "weather": [
                {"weather": {"platform": "demo"}},
                {
                    "platform": "template",
                    "name": "test",
                    "attribution_template": "{{ states('sensor.attribution') }}",
                    "condition_template": "sunny",
                    "forecast_template": "{{ states.weather.demo.attributes.forecast }}",
                    "temperature_template": "{{ states('sensor.temperature') | float }}",
                    "humidity_template": "{{ states('sensor.humidity') | int }}",
                    "pressure_template": "{{ states('sensor.pressure') }}",
                    "wind_speed_template": "{{ states('sensor.windspeed') }}",
                    "wind_bearing_template": "{{ states('sensor.windbearing') }}",
                    "ozone_template": "{{ states('sensor.ozone') }}",
                    "visibility_template": "{{ states('sensor.visibility') }}",
                },
            ]
        },
    )
    await hass.async_block_till_done()

    await hass.async_start()
    await hass.async_block_till_done()

    hass.states.async_set("sensor.attribution", "The custom attribution")
    await hass.async_block_till_done()
    hass.states.async_set("sensor.temperature", 22.3)
    await hass.async_block_till_done()
    hass.states.async_set("sensor.humidity", 60)
    await hass.async_block_till_done()
    hass.states.async_set("sensor.pressure", 1000)
    await hass.async_block_till_done()
    hass.states.async_set("sensor.windspeed", 20)
    await hass.async_block_till_done()
    hass.states.async_set("sensor.windbearing", 180)
    await hass.async_block_till_done()
    hass.states.async_set("sensor.ozone", 25)
    await hass.async_block_till_done()
    hass.states.async_set("sensor.visibility", 4.6)
    await hass.async_block_till_done()

    state = hass.states.get("weather.test")
    assert state is not None

    assert state.state == "sunny"

    data = state.attributes
    assert data.get(ATTR_WEATHER_ATTRIBUTION) == "The custom attribution"
    assert data.get(ATTR_WEATHER_TEMPERATURE) == 22.3
    assert data.get(ATTR_WEATHER_HUMIDITY) == 60
    assert data.get(ATTR_WEATHER_PRESSURE) == 1000
    assert data.get(ATTR_WEATHER_WIND_SPEED) == 20
    assert data.get(ATTR_WEATHER_WIND_BEARING) == 180
    assert data.get(ATTR_WEATHER_OZONE) == 25
    assert data.get(ATTR_WEATHER_VISIBILITY) == 4.6

@@ -44,16 +44,31 @@
 orm.%22%22%22%0A
+import pytest%0A%0A
 from hom
@@ -351,213 +351,111 @@
 ,%0A)%0A
-from homeassistant.setup import async_setup_component%0A%0A%0Aasync def test_template_state_text(hass):%0A    %22%22%22Test the state text of a template.%22%22%22%0A    await async_setup_component(%0A        hass,%0A        DOMAIN,
+%0A%0A@pytest.mark.parametrize(%22count,domain%22, %5B(1, DOMAIN)%5D)%0A@pytest.mark.parametrize(%0A    %22config%22,%0A    %5B
 %0A   
@@ -1470,166 +1470,236 @@
     
-)%0A    await hass.async_block_till_done()%0A%0A    await hass.async_start()%0A    await hass.async_block_till_done()%0A%0A    hass.states.async_set(%22sensor.attribution%22,
+%5D,%0A)%0Aasync def test_template_state_text(hass, start_ha):%0A    %22%22%22Test the state text of a template.%22%22%22%0A    for attr, v_attr, value in %5B%0A        (%0A            %22sensor.attribution%22,%0A            ATTR_WEATHER_ATTRIBUTION,%0A           
  %22Th
@@ -1723,638 +1723,487 @@
 ion%22
-)
+,
 %0A    
-await hass.async_block_till_done()%0A    hass.states.async_set(%22sensor.temperature%22
+    ),%0A        (%22sensor.temperature%22, ATTR_WEATHER_TEMPERATURE
 , 22.3)
+,
 %0A    
-await hass.async_block_till_done()%0A    hass.states.async_set(%22sensor.humidity%22
+    (%22sensor.humidity%22, ATTR_WEATHER_HUMIDITY
 , 60)
+,
 %0A    
-await hass.async_block_till_done()%0A    hass.states.async_set(%22sensor.pressure%22
+    (%22sensor.pressure%22, ATTR_WEATHER_PRESSURE
 , 1000)
+,
 %0A    
-await hass.async_block_till_done()%0A    hass.states.async_set(%22sensor.windspeed%22
+    (%22sensor.windspeed%22, ATTR_WEATHER_WIND_SPEED
 , 20)
+,
 %0A    
-await hass.async_block_till_done()%0A    hass.states.async_set(%22sensor.windbearing%22
+    (%22sensor.windbearing%22, ATTR_WEATHER_WIND_BEARING
 , 180)
+,
 %0A    
-await hass.async_block_till_done()%0A    hass.states.async_set(%22sensor.ozone%22
+    (%22sensor.ozone%22, ATTR_WEATHER_OZONE
 , 25)
+,
 %0A    
-await hass.async_block_till_done()%0A    hass.states.async_set(%22sensor.visibility%22, 4.6)%0A
+    (%22sensor.visibility%22, ATTR_WEATHER_VISIBILITY, 4.6),%0A    %5D:%0A        hass.states.async_set(attr, value)%0A    
     
@@ -2237,21 +2237,24 @@
 _done()%0A
-%0A
+ 
     
+   
 state = 
@@ -2285,16 +2285,20 @@
 .test%22)%0A
+    
     asse
@@ -2318,21 +2318,24 @@
 ot None%0A
-%0A
+  
     
+  
 assert s
@@ -2360,464 +2360,57 @@
 ny%22%0A
-%0A
     
-data = state.attributes%0A    assert data.get(ATTR_WEATHER_ATTRIBUTION) == %22The custom attribution%22%0A    assert data.get(ATTR_WEATHER_TEMPERATURE) == 22.3%0A    assert data.get(ATTR_WEATHER_HUMIDITY) == 60%0A    assert data.get(ATTR_WEATHER_PRESSURE) == 1000%0A    assert data.get(ATTR_WEATHER_WIND_SPEED) == 20%0A    assert data.get(ATTR_WEATHER_WIND_BEARING) == 180%0A    assert data.get(ATTR_WEATHER_OZONE) == 25%0A    assert data.get(ATTR_WEATHER_VISIBILITY) == 4.6
+    assert state.attributes.get(v_attr) == value
 %0A

Update template/test_weather.py to use pytest (#56223)