Mock with submodules for ReadTheDocs

冷暖自知 提交于 2019-12-04 03:57:30

A bit late… but I ran across this looking for a solution (using nested modules with mock). I've mocked module and submodules like this:

MOCK_MODULES = ['dbs', 'dbs.apis', 'dbs.apis.dbsClient']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

where the order mattered. Hope this helps anyone else looking to solve this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!