Speed up profiler lru test (#90395)
This commit is contained in:
parent
e0424c8322
commit
2fd872b253
1 changed files with 8 additions and 2 deletions
|
@ -10,6 +10,7 @@ import py
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.profiler import (
|
from homeassistant.components.profiler import (
|
||||||
|
_LRU_CACHE_WRAPPER_OBJECT,
|
||||||
CONF_SECONDS,
|
CONF_SECONDS,
|
||||||
SERVICE_DUMP_LOG_OBJECTS,
|
SERVICE_DUMP_LOG_OBJECTS,
|
||||||
SERVICE_LOG_EVENT_LOOP_SCHEDULED,
|
SERVICE_LOG_EVENT_LOOP_SCHEDULED,
|
||||||
|
@ -253,10 +254,15 @@ async def test_lru_stats(hass: HomeAssistant, caplog: pytest.LogCaptureFixture)
|
||||||
domain_data = DomainData()
|
domain_data = DomainData()
|
||||||
assert hass.services.has_service(DOMAIN, SERVICE_LRU_STATS)
|
assert hass.services.has_service(DOMAIN, SERVICE_LRU_STATS)
|
||||||
|
|
||||||
await hass.services.async_call(DOMAIN, SERVICE_LRU_STATS, blocking=True)
|
def _mock_by_type(type_):
|
||||||
|
if type_ == _LRU_CACHE_WRAPPER_OBJECT:
|
||||||
|
return [_dummy_test_lru_stats]
|
||||||
|
return [domain_data]
|
||||||
|
|
||||||
|
with patch("objgraph.by_type", side_effect=_mock_by_type):
|
||||||
|
await hass.services.async_call(DOMAIN, SERVICE_LRU_STATS, blocking=True)
|
||||||
|
|
||||||
assert "DomainData" in caplog.text
|
assert "DomainData" in caplog.text
|
||||||
assert "(0, 0)" in caplog.text
|
assert "(0, 0)" in caplog.text
|
||||||
assert "_dummy_test_lru_stats" in caplog.text
|
assert "_dummy_test_lru_stats" in caplog.text
|
||||||
assert "CacheInfo" in caplog.text
|
assert "CacheInfo" in caplog.text
|
||||||
del domain_data
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue