mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
doc: Indroduce MOCK_MODULES_MAPPING
Some mocks needs some attributes defined (instead of having them returning a mock object). Introduce a MOCK_MODULES_MAPPING mapping that defines these attributes. This gets rid of a special handling for psutil. Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
This commit is contained in:
parent
cf648246ea
commit
ecdb452e8a
1 changed files with 10 additions and 9 deletions
19
doc/conf.py
19
doc/conf.py
|
@ -193,22 +193,23 @@ MOCK_MODULES = [
|
|||
'msgpack',
|
||||
]
|
||||
|
||||
for mod_name in MOCK_MODULES:
|
||||
if mod_name == 'psutil':
|
||||
mock = Mock(mapping={'total': 0}) # Otherwise it will crash Sphinx
|
||||
else:
|
||||
mock = Mock()
|
||||
sys.modules[mod_name] = mock
|
||||
MOCK_MODULES_MAPPING = {
|
||||
'cherrypy': {'config': mock_decorator_with_params},
|
||||
'ntsecuritycon': {
|
||||
'STANDARD_RIGHTS_REQUIRED': 0,
|
||||
'SYNCHRONIZE': 0,
|
||||
},
|
||||
'psutil': {'total': 0}, # Otherwise it will crash Sphinx
|
||||
}
|
||||
|
||||
for mod_name in MOCK_MODULES:
|
||||
sys.modules[mod_name] = Mock(mapping=MOCK_MODULES_MAPPING.get(mod_name))
|
||||
|
||||
# Define a fake version attribute for the following libs.
|
||||
sys.modules['libcloud'].__version__ = '0.0.0'
|
||||
sys.modules['msgpack'].version = (1, 0, 0)
|
||||
sys.modules['psutil'].version_info = (3, 0, 0)
|
||||
sys.modules['pymongo'].version = '0.0.0'
|
||||
sys.modules['ntsecuritycon'].STANDARD_RIGHTS_REQUIRED = 0
|
||||
sys.modules['ntsecuritycon'].SYNCHRONIZE = 0
|
||||
sys.modules['cherrypy'].config = mock_decorator_with_params
|
||||
sys.modules['tornado'].version_info = (0, 0, 0)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue