docs: Improve the Mock class
The python import machinery expects __path__ to be a string, so __getattr__ has to return a mock string instead of a mock object. __getattr__ now also returns Mock objects instead of the Mock class and Mock objects are now callable.rtd2
parent
34d1392e6e
commit
178a68a17f
|
@ -38,9 +38,13 @@ You can mock out the imports for these modules in your conf.py with the followin
|
|||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def __getattr__(self, name):
|
||||
def __call__(self, *args, **kwargs):
|
||||
return Mock()
|
||||
|
||||
@classmethod
|
||||
def __getattr__(self, name):
|
||||
return Mock() if name not in ('__file__', '__path__') else '/dev/null'
|
||||
|
||||
MOCK_MODULES = ['pygtk', 'gtk', 'gobject', 'argparse']
|
||||
for mod_name in MOCK_MODULES:
|
||||
sys.modules[mod_name] = Mock()
|
||||
|
|
Loading…
Reference in New Issue