Handle mock imports for non-platform-agnostic modules
This commit is contained in:
parent
259ec4150f
commit
8490d028a5
2 changed files with 23 additions and 4 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
Sphinx
|
Sphinx
|
||||||
sphinxcontrib-httpdomain
|
sphinxcontrib-httpdomain
|
||||||
sphinx_rtd_theme
|
sphinx_rtd_theme
|
||||||
|
openflexure-stage
|
||||||
|
Pillow
|
||||||
|
pyyaml
|
||||||
|
|
@ -12,10 +12,26 @@
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# 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.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#
|
#
|
||||||
# import os
|
import os
|
||||||
# import sys
|
import sys
|
||||||
# sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
|
|
||||||
|
# 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 -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue