mocksafe.mock_module
- mocksafe.mock_module(module: M, name: str | None = None) M
Creates a mocked version of the given
module.- Parameters:
module (M) – module to be mocked of generic ModuleType
Mname (str, optional) – optional custom name to help identify the mock object in str representations
- Returns:
a mock object but typed with the generic ModuleType
M- Return type:
M
- Example:
>>> import random >>> mock_random = mock_module(random) >>> mock_random SafeMock(<class 'MockSpec(module=random)'>, <module 'random' from '.../random.py'>)
To stub a mocked function on the module see:
To assert calls made to a mocked function see:
To retrieve calls that were made to a mocked function see: