mock_now#
- langchain_core.utils.utils.mock_now(dt_value: datetime) Iterator[type] [source]#
Context manager for mocking out datetime.now() in unit tests.
- Parameters:
dt_value (datetime) – The datetime value to use for datetime.now().
- Yields:
datetime.datetime – The mocked datetime class.
- Return type:
Iterator[type]
Example: with mock_now(datetime.datetime(2011, 2, 3, 10, 11)):
assert datetime.datetime.now() == datetime.datetime(2011, 2, 3, 10, 11)
Examples using mock_now