mock_now#

langchain_core.utils.utils.mock_now(dt_value)[source]#

Context manager for mocking out datetime.now() in unit tests.

Parameters:

dt_value – The datetime value to use for datetime.now().

Yields:

datetime.datetime – The mocked datetime class.

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