libb.patch_library_config
- patch_library_config(library_name, config_name='config', **config_overrides)[source]
Patch a library’s config module directly in sys.modules.
Finds and patches the library’s config module before the library imports it. Works regardless of import order by patching the config module directly.
- Parameters:
- Return type:
Example:
>>> import sys >>> from libb import create_mock_module >>> Setting.unlock() >>> api = Setting() >>> api.key = 'oldkey' >>> Setting.lock() >>> create_mock_module('mylib', {}) # parent module >>> create_mock_module('mylib.config', {'api': api}) >>> patch_library_config('mylib', api_key='newkey') >>> sys.modules['mylib.config'].api.key 'newkey'