mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
doc: Move mock_decorator_with_params up
Refactor conf.py and move mock_decorator_with_params for the following commit. Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
This commit is contained in:
parent
08ef6694ea
commit
cf648246ea
1 changed files with 17 additions and 17 deletions
34
doc/conf.py
34
doc/conf.py
|
@ -59,6 +59,23 @@ class Mock(object):
|
|||
next = __next__
|
||||
|
||||
|
||||
def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Optionally mock a decorator that takes parameters
|
||||
|
||||
E.g.:
|
||||
|
||||
@blah(stuff=True)
|
||||
def things():
|
||||
pass
|
||||
'''
|
||||
def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument
|
||||
if hasattr(fn, '__call__'):
|
||||
return fn
|
||||
return Mock()
|
||||
return inner
|
||||
|
||||
|
||||
MOCK_MODULES = [
|
||||
# Python stdlib
|
||||
'user',
|
||||
|
@ -184,23 +201,6 @@ for mod_name in MOCK_MODULES:
|
|||
sys.modules[mod_name] = mock
|
||||
|
||||
|
||||
def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Optionally mock a decorator that takes parameters
|
||||
|
||||
E.g.:
|
||||
|
||||
@blah(stuff=True)
|
||||
def things():
|
||||
pass
|
||||
'''
|
||||
def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument
|
||||
if hasattr(fn, '__call__'):
|
||||
return fn
|
||||
return Mock()
|
||||
return inner
|
||||
|
||||
|
||||
# Define a fake version attribute for the following libs.
|
||||
sys.modules['libcloud'].__version__ = '0.0.0'
|
||||
sys.modules['msgpack'].version = (1, 0, 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue