From 8490d028a50bcd3eef823a5f64eac58de6949d08 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 19 Nov 2018 17:35:40 +0000 Subject: [PATCH] Handle mock imports for non-platform-agnostic modules --- doc/requirements.txt | 5 ++++- doc/source/conf.py | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 45ac0217..10c9c94d 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,3 +1,6 @@ Sphinx sphinxcontrib-httpdomain -sphinx_rtd_theme \ No newline at end of file +sphinx_rtd_theme +openflexure-stage +Pillow +pyyaml \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 580a1c32..1c914c2c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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 -----------------------------------------------------