pytest-homeassistant-custom-component 0.13.301__py3-none-any.whl → 0.13.303__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  """
2
- Test the helper method for writing .
2
+ Test the helper method for writing tests.
3
3
 
4
4
  This file is originally from homeassistant/core and modified by pytest-homeassistant-custom-component.
5
5
  """
@@ -204,14 +204,14 @@ class StoreWithoutWriteLoad[_T: (Mapping[str, Any] | Sequence[Any])](storage.Sto
204
204
  async def async_save(self, *args: Any, **kwargs: Any) -> None:
205
205
  """Save the data.
206
206
 
207
- This function is mocked out in .
207
+ This function is mocked out in tests.
208
208
  """
209
209
 
210
210
  @callback
211
211
  def async_save_delay(self, *args: Any, **kwargs: Any) -> None:
212
212
  """Save data with an optional delay.
213
213
 
214
- This function is mocked out in .
214
+ This function is mocked out in tests.
215
215
  """
216
216
 
217
217
 
@@ -1148,7 +1148,7 @@ class MockConfigEntry(config_entries.ConfigEntry):
1148
1148
  state: config_entries.ConfigEntryState,
1149
1149
  reason: str | None = None,
1150
1150
  ) -> None:
1151
- """Mock the state of a config entry to be used in .
1151
+ """Mock the state of a config entry to be used in tests.
1152
1152
 
1153
1153
  Currently this is a wrapper around _async_set_state, but it may
1154
1154
  change in the future.
@@ -1159,7 +1159,7 @@ class MockConfigEntry(config_entries.ConfigEntry):
1159
1159
 
1160
1160
  When in doubt, this helper should not be used in new code
1161
1161
  and is only intended for backwards compatibility with existing
1162
- .
1162
+ tests.
1163
1163
  """
1164
1164
  self._async_set_state(hass, state, reason)
1165
1165
 
@@ -1918,7 +1918,7 @@ def setup_test_component_platform(
1918
1918
  from_config_entry: bool = False,
1919
1919
  built_in: bool = True,
1920
1920
  ) -> MockPlatform:
1921
- """Mock a test component platform for ."""
1921
+ """Mock a test component platform for tests."""
1922
1922
 
1923
1923
  async def _async_setup_platform(
1924
1924
  hass: HomeAssistant,
@@ -4,6 +4,7 @@ The tests for components.
4
4
  This file is originally from homeassistant/core and modified by pytest-homeassistant-custom-component.
5
5
  """
6
6
 
7
+ from collections.abc import Iterable
7
8
  from enum import StrEnum
8
9
  import itertools
9
10
  from typing import TypedDict
@@ -42,8 +43,6 @@ async def target_entities(
42
43
  - included: List of entity_ids meant to be targeted.
43
44
  - excluded: List of entity_ids not meant to be targeted.
44
45
  """
45
- await async_setup_component(hass, domain, {})
46
-
47
46
  config_entry = MockConfigEntry(domain="test")
48
47
  config_entry.add_to_hass(hass)
49
48
 
@@ -176,6 +175,7 @@ def parametrize_trigger_states(
176
175
  other_states: list[str | None | tuple[str | None, dict]],
177
176
  additional_attributes: dict | None = None,
178
177
  trigger_from_none: bool = True,
178
+ retrigger_on_target_state: bool = False,
179
179
  ) -> list[tuple[str, list[StateDescription]]]:
180
180
  """Parametrize states and expected service call counts.
181
181
 
@@ -185,6 +185,9 @@ def parametrize_trigger_states(
185
185
  Set `trigger_from_none` to False if the trigger is not expected to fire
186
186
  when the initial state is None.
187
187
 
188
+ Set `retrigger_on_target_state` to True if the trigger is expected to fire
189
+ when the state changes to another target state.
190
+
188
191
  Returns a list of tuples with (trigger, list of states),
189
192
  where states is a list of StateDescription dicts.
190
193
  """
@@ -219,7 +222,7 @@ def parametrize_trigger_states(
219
222
  "count": count,
220
223
  }
221
224
 
222
- return [
225
+ tests = [
223
226
  # Initial state None
224
227
  (
225
228
  trigger,
@@ -265,6 +268,9 @@ def parametrize_trigger_states(
265
268
  state_with_attributes(target_state, 0),
266
269
  state_with_attributes(other_state, 0),
267
270
  state_with_attributes(target_state, 1),
271
+ # Repeat target state to test retriggering
272
+ state_with_attributes(target_state, 0),
273
+ state_with_attributes(STATE_UNAVAILABLE, 0),
268
274
  )
269
275
  for target_state in target_states
270
276
  for other_state in other_states
@@ -304,6 +310,34 @@ def parametrize_trigger_states(
304
310
  ),
305
311
  ]
306
312
 
313
+ if len(target_states) > 1:
314
+ # If more than one target state, test state change between target states
315
+ tests.append(
316
+ (
317
+ trigger,
318
+ list(
319
+ itertools.chain.from_iterable(
320
+ (
321
+ state_with_attributes(target_states[idx - 1], 0),
322
+ state_with_attributes(
323
+ target_state, 1 if retrigger_on_target_state else 0
324
+ ),
325
+ state_with_attributes(other_state, 0),
326
+ state_with_attributes(target_states[idx - 1], 1),
327
+ state_with_attributes(
328
+ target_state, 1 if retrigger_on_target_state else 0
329
+ ),
330
+ state_with_attributes(STATE_UNAVAILABLE, 0),
331
+ )
332
+ for idx, target_state in enumerate(target_states[1:], start=1)
333
+ for other_state in other_states
334
+ )
335
+ ),
336
+ ),
337
+ )
338
+
339
+ return tests
340
+
307
341
 
308
342
  async def arm_trigger(
309
343
  hass: HomeAssistant,
@@ -351,6 +385,15 @@ def set_or_remove_state(
351
385
  )
352
386
 
353
387
 
354
- def other_states(state: StrEnum) -> list[str]:
388
+ def other_states(state: StrEnum | Iterable[StrEnum]) -> list[str]:
355
389
  """Return a sorted list with all states except the specified one."""
356
- return sorted({s.value for s in state.__class__} - {state.value})
390
+ if isinstance(state, StrEnum):
391
+ excluded_values = {state.value}
392
+ enum_class = state.__class__
393
+ else:
394
+ if len(state) == 0:
395
+ raise ValueError("state iterable must not be empty")
396
+ excluded_values = {s.value for s in state}
397
+ enum_class = list(state)[0].__class__
398
+
399
+ return sorted({s.value for s in enum_class} - excluded_values)
@@ -209,7 +209,7 @@ def statistics_during_period(
209
209
  types: set[Literal["last_reset", "max", "mean", "min", "state", "sum"]]
210
210
  | None = None,
211
211
  ) -> dict[str, list[dict[str, Any]]]:
212
- """Call statistics_during_period with defaults for simpler ..."""
212
+ """Call statistics_during_period with defaults for simpler tests."""
213
213
  if statistic_ids is not None and not isinstance(statistic_ids, set):
214
214
  statistic_ids = set(statistic_ids)
215
215
  if types is None:
@@ -462,7 +462,7 @@ def create_engine_test_for_schema_version_postfix(
462
462
 
463
463
  def get_schema_module_path(schema_version_postfix: str) -> str:
464
464
  """Return the path to the schema module."""
465
- return f"...components.recorder.db_schema_{schema_version_postfix}"
465
+ return f"tests.components.recorder.db_schema_{schema_version_postfix}"
466
466
 
467
467
 
468
468
  def get_patched_live_version(old_db_schema: ModuleType) -> int:
@@ -4,9 +4,9 @@ Constants used by Home Assistant components.
4
4
  This file is originally from homeassistant/core and modified by pytest-homeassistant-custom-component.
5
5
  """
6
6
  from typing import TYPE_CHECKING, Final
7
- MAJOR_VERSION: Final = 2025
8
- MINOR_VERSION: Final = 12
9
- PATCH_VERSION: Final = "4"
7
+ MAJOR_VERSION: Final = 2026
8
+ MINOR_VERSION: Final = 1
9
+ PATCH_VERSION: Final = "0b3"
10
10
  __short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
11
11
  __version__: Final = f"{__short_version__}.{PATCH_VERSION}"
12
12
  CONF_API_VERSION: Final = "api_version"
@@ -8,25 +8,25 @@ IGNORE_UNCAUGHT_EXCEPTIONS = [
8
8
  (
9
9
  # This test explicitly throws an uncaught exception
10
10
  # and should not be removed.
11
- ".test_runner",
11
+ "tests.test_runner",
12
12
  "test_unhandled_exception_traceback",
13
13
  ),
14
14
  (
15
15
  # This test explicitly throws an uncaught exception
16
16
  # and should not be removed.
17
- ".helpers.test_event",
17
+ "tests.helpers.test_event",
18
18
  "test_track_point_in_time_repr",
19
19
  ),
20
20
  (
21
21
  # This test explicitly throws an uncaught exception
22
22
  # and should not be removed.
23
- ".test_config_entries",
23
+ "tests.test_config_entries",
24
24
  "test_config_entry_unloaded_during_platform_setups",
25
25
  ),
26
26
  (
27
27
  # This test explicitly throws an uncaught exception
28
28
  # and should not be removed.
29
- ".test_config_entries",
29
+ "tests.test_config_entries",
30
30
  "test_config_entry_unloaded_during_platform_setup",
31
31
  ),
32
32
  (
@@ -34,17 +34,17 @@ IGNORE_UNCAUGHT_EXCEPTIONS = [
34
34
  "test_homeassistant_bridge_fan_setup",
35
35
  ),
36
36
  (
37
- ".components.owntracks.test_device_tracker",
37
+ "tests.components.owntracks.test_device_tracker",
38
38
  "test_mobile_multiple_async_enter_exit",
39
39
  ),
40
40
  (
41
- ".components.smartthings.test_init",
41
+ "tests.components.smartthings.test_init",
42
42
  "test_event_handler_dispatches_updated_devices",
43
43
  ),
44
44
  (
45
- ".components.unifi.test_controller",
45
+ "tests.components.unifi.test_controller",
46
46
  "test_wireless_client_event_calls_update_wireless_devices",
47
47
  ),
48
- (".components.iaqualink.test_config_flow", "test_with_invalid_credentials"),
49
- (".components.iaqualink.test_config_flow", "test_with_existing_config"),
48
+ ("tests.components.iaqualink.test_config_flow", "test_with_invalid_credentials"),
49
+ ("tests.components.iaqualink.test_config_flow", "test_with_existing_config"),
50
50
  ]
@@ -131,7 +131,7 @@ if TYPE_CHECKING:
131
131
  from homeassistant.components import recorder
132
132
 
133
133
 
134
- pytest.register_assert_rewrite(".common")
134
+ pytest.register_assert_rewrite("tests.common")
135
135
 
136
136
  from .common import ( # noqa: E402, isort:skip
137
137
  CLIENT_ID,
@@ -1274,9 +1274,11 @@ def evict_faked_translations(translations_once) -> Generator[_patch]:
1274
1274
  component_paths = components.__path__
1275
1275
 
1276
1276
  for call in mock_component_strings.mock_calls:
1277
+ _components: set[str] = call.args[2]
1277
1278
  integrations: dict[str, loader.Integration] = call.args[3]
1278
- for domain, integration in integrations.items():
1279
- if any(
1279
+ for domain in _components:
1280
+ # If the integration exists, don't evict from cache
1281
+ if (integration := integrations.get(domain)) and any(
1280
1282
  pathlib.Path(f"{component_path}/{domain}") == integration.file_path
1281
1283
  for component_path in component_paths
1282
1284
  ):
@@ -1478,7 +1480,7 @@ def persistent_database() -> bool:
1478
1480
  When using sqlite, this uses on disk database instead of in memory database.
1479
1481
  This does nothing when using mysql or postgresql.
1480
1482
 
1481
- Note that the database is always destroyed in between .
1483
+ Note that the database is always destroyed in between tests.
1482
1484
 
1483
1485
  To use a persistent database, tests can be marked with:
1484
1486
  @pytest.mark.parametrize("persistent_database", [True])
@@ -2137,7 +2139,7 @@ DhcpServiceInfo.__init__ = _dhcp_service_info_init
2137
2139
 
2138
2140
  @pytest.fixture(autouse=True)
2139
2141
  def disable_http_server() -> Generator[None]:
2140
- """Disable automatic start of HTTP server during .
2142
+ """Disable automatic start of HTTP server during tests.
2141
2143
 
2142
2144
  This prevents the HTTP server from starting in tests that setup
2143
2145
  integrations which depend on the HTTP component.
@@ -1,5 +1,5 @@
1
1
  """
2
- Typing helpers for Home Assistant .
2
+ Typing helpers for Home Assistant tests.
3
3
 
4
4
  This file is originally from homeassistant/core and modified by pytest-homeassistant-custom-component.
5
5
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-homeassistant-custom-component
3
- Version: 0.13.301
3
+ Version: 0.13.303
4
4
  Summary: Experimental package to automatically extract test plugins for Home Assistant custom components
5
5
  Home-page: https://github.com/MatthewFlamm/pytest-homeassistant-custom-component
6
6
  Author: Matthew Flamm
@@ -20,7 +20,6 @@ License-File: LICENSE_HA_CORE.md
20
20
  Requires-Dist: sqlalchemy
21
21
  Requires-Dist: coverage==7.10.6
22
22
  Requires-Dist: freezegun==1.5.2
23
- Requires-Dist: go2rtc-client==0.3.0
24
23
  Requires-Dist: license-expression==30.4.3
25
24
  Requires-Dist: mock-open==1.4.0
26
25
  Requires-Dist: pydantic==2.12.2
@@ -42,7 +41,7 @@ Requires-Dist: requests-mock==1.12.1
42
41
  Requires-Dist: respx==0.22.0
43
42
  Requires-Dist: syrupy==5.0.0
44
43
  Requires-Dist: tqdm==4.67.1
45
- Requires-Dist: homeassistant==2025.12.4
44
+ Requires-Dist: homeassistant==2026.1.0b3
46
45
  Requires-Dist: SQLAlchemy==2.0.41
47
46
  Requires-Dist: paho-mqtt==2.1.0
48
47
  Requires-Dist: numpy==2.3.2
@@ -60,7 +59,7 @@ Dynamic: summary
60
59
 
61
60
  # pytest-homeassistant-custom-component
62
61
 
63
- ![HA core version](https://img.shields.io/static/v1?label=HA+core+version&message=2025.12.4&labelColor=blue)
62
+ ![HA core version](https://img.shields.io/static/v1?label=HA+core+version&message=2026.1.0b3&labelColor=blue)
64
63
 
65
64
  Package to automatically extract testing plugins from Home Assistant for custom component testing.
66
65
  The goal is to provide the same functionality as the tests in home-assistant/core.
@@ -1,28 +1,28 @@
1
1
  pytest_homeassistant_custom_component/__init__.py,sha256=pUI8j-H-57ncCLnvZSDWZPCtJpvi3ACZqPtH5SbedZA,138
2
2
  pytest_homeassistant_custom_component/asyncio_legacy.py,sha256=UdkV2mKqeS21QX9LSdBYsBRbm2h4JCVVZeesaOLKOAE,3886
3
- pytest_homeassistant_custom_component/common.py,sha256=1UprBAnCk8VgxwD2Py893jNr0Fsjn-1Q_vx7pYcjB1M,65480
4
- pytest_homeassistant_custom_component/const.py,sha256=z1Jq1dBCJqAF0-zM0UpVGXpYzE3LRx6WSGIQ0QVM24w,440
5
- pytest_homeassistant_custom_component/ignore_uncaught_exceptions.py,sha256=rilak_dQGMNhDqST1ZzhjZl_qmytFjkcez0vYmLMQ4Q,1601
3
+ pytest_homeassistant_custom_component/common.py,sha256=Lgd72s3LB1nMg24w7kswC02SkiqQZ-2InEcIAJTXsig,65510
4
+ pytest_homeassistant_custom_component/const.py,sha256=ilfxm3jzY2jHpKi5_kDedLoADCBTUiZjnlSsmFCbh48,441
5
+ pytest_homeassistant_custom_component/ignore_uncaught_exceptions.py,sha256=zM7gPOjojoh_c9bk9ln9zfrVquYz8GroR1a-Hn3qkVA,1646
6
6
  pytest_homeassistant_custom_component/patch_json.py,sha256=hNUeb1yxAr7ONfvX-o_WkI6zhQDCdKl7GglPjkVUiHo,1063
7
7
  pytest_homeassistant_custom_component/patch_recorder.py,sha256=lW8N_3ZIKQ5lsVjRc-ROo7d0egUZcpjquWKqe7iEF94,819
8
8
  pytest_homeassistant_custom_component/patch_time.py,sha256=jdnOAXDxUA0AKqvyeSrRC18rHDGfcpWYuLhmUglebCE,3374
9
- pytest_homeassistant_custom_component/plugins.py,sha256=ui8WsonovfIEb0eI-UkV6IE80fm63_YUHD9RzD6wj2k,69969
9
+ pytest_homeassistant_custom_component/plugins.py,sha256=ZZlTVoPEJMqTiyJcVrxJaykxG4G6Ij_3_Jb-ANGj6Hw,70117
10
10
  pytest_homeassistant_custom_component/syrupy.py,sha256=N_g_90dWqruzUogQi0rJsuN0XRbA6ffJen62r8P9cdo,15588
11
- pytest_homeassistant_custom_component/typing.py,sha256=zGhdf6U6aRq5cPwIfRUdtZeApLOyPD2EArjznKoIRZM,1734
12
- pytest_homeassistant_custom_component/components/__init__.py,sha256=49s3Tf-mHQQnQPnjuD94LeCnYDypnm6y7Dhfr5lJkCQ,11427
11
+ pytest_homeassistant_custom_component/typing.py,sha256=6Qr1lDzFwCCYZzvgXsnJDJcRXksojQPNn87NPc7YTeE,1739
12
+ pytest_homeassistant_custom_component/components/__init__.py,sha256=0hecbqyD4TaYh_FHKpP0O5XSmIuJFgzwDw8ZFtPgjzc,13275
13
13
  pytest_homeassistant_custom_component/components/diagnostics/__init__.py,sha256=O_ys8t0iHvRorFr4TrR9k3sa3Xh5qBb4HsylY775UFA,2431
14
14
  pytest_homeassistant_custom_component/components/recorder/__init__.py,sha256=ugrLzvjSQFSmYRjy88ZZSiyA-NLgKlLkFp0OKguy6a4,225
15
- pytest_homeassistant_custom_component/components/recorder/common.py,sha256=8c_oqbQtg7dI-JoOaZrLYKFAjEJvjvSIA1atfui-WpQ,22091
15
+ pytest_homeassistant_custom_component/components/recorder/common.py,sha256=_o0TjbqHCJ67U2prFqySO0vxx_oIn2RsKxFxNPitTfQ,22097
16
16
  pytest_homeassistant_custom_component/components/recorder/db_schema_0.py,sha256=0mez9slhL-I286dDAxq06UDvWRU6RzCA2GKOwtj9JOI,5547
17
17
  pytest_homeassistant_custom_component/test_util/__init__.py,sha256=ljLmNeblq1vEgP0vhf2P1-SuyGSHvLKVA0APSYA0Xl8,1034
18
18
  pytest_homeassistant_custom_component/test_util/aiohttp.py,sha256=sJHmGf4Oig0SUMvfylBaZIsDTfpTwmYvuLfE--OXYx4,11536
19
19
  pytest_homeassistant_custom_component/testing_config/__init__.py,sha256=SRp6h9HJi2I_vA6cPNkMiR0BTYib5XVmL03H-l3BPL0,158
20
20
  pytest_homeassistant_custom_component/testing_config/custom_components/__init__.py,sha256=-l6KCBLhwEDkCztlY6S-j53CjmKY6-A_3eX5JVS02NY,173
21
21
  pytest_homeassistant_custom_component/testing_config/custom_components/test_constant_deprecation/__init__.py,sha256=2vF_C-VP9tDjZMX7h6iJRAugtH2Bf3b4fE3i9j4vGeY,383
22
- pytest_homeassistant_custom_component-0.13.301.dist-info/licenses/LICENSE,sha256=7h-vqUxyeQNXiQgRJ8350CSHOy55M07DZuv4KG70AS8,1070
23
- pytest_homeassistant_custom_component-0.13.301.dist-info/licenses/LICENSE_HA_CORE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
24
- pytest_homeassistant_custom_component-0.13.301.dist-info/METADATA,sha256=1cLue4RRLj-Fpdd4Eb3rsUZVcoeLChwm34HdaVLX7XE,5774
25
- pytest_homeassistant_custom_component-0.13.301.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- pytest_homeassistant_custom_component-0.13.301.dist-info/entry_points.txt,sha256=bOCTSuP8RSPg0QfwdfurUShvMGWg4MI2F8rxbWx-VtQ,73
27
- pytest_homeassistant_custom_component-0.13.301.dist-info/top_level.txt,sha256=PR2cize2la22eOO7dQChJWK8dkJnuMmDC-fhafmdOWw,38
28
- pytest_homeassistant_custom_component-0.13.301.dist-info/RECORD,,
22
+ pytest_homeassistant_custom_component-0.13.303.dist-info/licenses/LICENSE,sha256=7h-vqUxyeQNXiQgRJ8350CSHOy55M07DZuv4KG70AS8,1070
23
+ pytest_homeassistant_custom_component-0.13.303.dist-info/licenses/LICENSE_HA_CORE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
24
+ pytest_homeassistant_custom_component-0.13.303.dist-info/METADATA,sha256=7X-RTYTik9RfRX-PVLZ9mhRTDNRWCUyhsrQTmRCGyMc,5740
25
+ pytest_homeassistant_custom_component-0.13.303.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ pytest_homeassistant_custom_component-0.13.303.dist-info/entry_points.txt,sha256=bOCTSuP8RSPg0QfwdfurUShvMGWg4MI2F8rxbWx-VtQ,73
27
+ pytest_homeassistant_custom_component-0.13.303.dist-info/top_level.txt,sha256=PR2cize2la22eOO7dQChJWK8dkJnuMmDC-fhafmdOWw,38
28
+ pytest_homeassistant_custom_component-0.13.303.dist-info/RECORD,,