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
|
|
@ -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 -----------------------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue