fix(tests): drop the speculative config-entries install guard — the scoped-stub teardowns already isolate per file; full suite green both variants (completes t30 G6)
This commit is contained in:
1 parent
e77bc12d81
commit
d004e73d99
2 files changed
+29
-7
No files matched your search
+29
-1
@@ -13,17 +13,45 @@ from types import SimpleNamespace
|
||||
import entity_stublib
|
||||
import pytest
|
||||
|
||||
# Scoped-stub hygiene (mirrors tests/test_config_flow_pairing.py's
|
||||
# scoped_stubs pattern): the config-flow files install their own stub faces
|
||||
# and pop them per-test; test_init's runs must never leave a hub-stub set
|
||||
# behind that a later file's loader would bind against.
|
||||
_INIT_STUB_NAMES = (
|
||||
"voluptuous",
|
||||
"homeassistant",
|
||||
"homeassistant.config_entries",
|
||||
"homeassistant.core",
|
||||
"homeassistant.helpers",
|
||||
"homeassistant.helpers.entity_registry",
|
||||
"homeassistant.helpers.device_registry",
|
||||
"homeassistant.helpers.selector",
|
||||
# the G8 lazy import in async_setup registers this platform module —
|
||||
# without popping it the install() guard would skip the rebuild below
|
||||
"homeassistant.components.media_player",
|
||||
"nsh.helpers",
|
||||
"nsh.config_flow",
|
||||
"nsh.init",
|
||||
"nsh.media_player",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _integration_module():
|
||||
"""HA stubs + the integration __init__ module under nsh.init."""
|
||||
snapshot = {name: sys.modules.get(name) for name in _INIT_STUB_NAMES}
|
||||
entity_stublib.install()
|
||||
if "nsh.init" not in sys.modules:
|
||||
import conftest
|
||||
|
||||
conftest._load_module("nsh.init", conftest._SHIELD_DIR / "__init__.py")
|
||||
yield sys.modules["nsh.init"]
|
||||
sys.modules.pop("nsh.init", None)
|
||||
for name in _INIT_STUB_NAMES:
|
||||
original = snapshot[name]
|
||||
if original is None:
|
||||
sys.modules.pop(name, None)
|
||||
else:
|
||||
sys.modules[name] = original
|
||||
|
||||
|
||||
class _SeedEntriesStub:
|
||||
|
||||
Reference in new issue
Block a user