mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Small speed up to frequently called datetime functions (#85399)
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from collections.abc import AsyncGenerator, Callable, Generator
|
||||
from contextlib import asynccontextmanager
|
||||
import datetime
|
||||
import functools
|
||||
import gc
|
||||
import itertools
|
||||
@@ -78,6 +79,14 @@ asyncio.set_event_loop_policy(runner.HassEventLoopPolicy(False))
|
||||
asyncio.set_event_loop_policy = lambda policy: None
|
||||
|
||||
|
||||
def _utcnow():
|
||||
"""Make utcnow patchable by freezegun."""
|
||||
return datetime.datetime.now(datetime.timezone.utc)
|
||||
|
||||
|
||||
dt_util.utcnow = _utcnow
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
"""Register custom pytest options."""
|
||||
parser.addoption("--dburl", action="store", default="sqlite://")
|
||||
|
||||
Reference in New Issue
Block a user