Handle mock imports for non-platform-agnostic modules

This commit is contained in:
Joel Collins 2018-11-19 17:35:40 +00:00
parent 259ec4150f
commit 8490d028a5
2 changed files with 23 additions and 4 deletions

View file

@ -1,3 +1,6 @@
Sphinx
sphinxcontrib-httpdomain
sphinx_rtd_theme
sphinx_rtd_theme
openflexure-stage
Pillow
pyyaml

View file

@ -12,10 +12,26 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys
# Load module from relative imports
module_path = os.path.abspath('../..')
sys.path.insert(0, module_path)
# Handle mock imports for non-platform-agnostic modules
from unittest.mock import MagicMock
class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return MagicMock()
mock_imports = ['picamera', 'picamera.array', 'picamera.mmalobj']
sys.modules.update((mod_name, Mock()) for mod_name in mock_imports)
# -- Project information -----------------------------------------------------