From f7fff90a6f161c88707ead4cc66d01366208e0fb Mon Sep 17 00:00:00 2001 From: Karl Nelson Date: Mon, 24 Jun 2019 11:18:39 -0700 Subject: [PATCH 1/2] Removed mock. --- doc/conf.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 0cdf0f29a..a46ca5562 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -53,10 +53,26 @@ # built documents. # # The short X.Y version. -import mock -mock_modules = ('_jpype',) -for m in mock_modules: - sys.modules[m] = mock.MagicMock() + +class JPypeFake(object): + def setResource(*args): + pass + def isStarted(*args): + return False + class PyJPClass(object): + pass + class PyJPMethod(object): + pass + class PyJPField(object): + pass + class PyJPArray(object): + pass +sys.modules['_jpype'] = JPypeFake() + +# For some reason jpype.imports does not work if called in sphinx. Importing +# it here solved the problem. +import jpype +import jpype.imports import jpype # TODO: reconsider this From 122607fcf7d8aee003770b08b80a7508ecc1865b Mon Sep 17 00:00:00 2001 From: Karl Nelson Date: Mon, 24 Jun 2019 14:41:58 -0700 Subject: [PATCH 2/2] Remove extra import. --- doc/conf.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a46ca5562..c80e1e2c1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -53,34 +53,34 @@ # built documents. # # The short X.Y version. - -class JPypeFake(object): - def setResource(*args): - pass - def isStarted(*args): - return False - class PyJPClass(object): - pass - class PyJPMethod(object): +import mock +class TypeMock(type): + def __new__(cls, name, bases=None, methods={}): + if not bases: + bases = tuple() + methods['__init__'] = TypeMock._init + methods['__getattr__'] = TypeMock.__getattr__ + return type.__new__(cls, name, bases, methods) + + def __init__(self, name, bases=None, methods={}): pass - class PyJPField(object): - pass - class PyJPArray(object): + + def _init(self, *args): pass -sys.modules['_jpype'] = JPypeFake() + + def __getattr__(self, key): + print("get",key) + return mock.Mock() + +mockModule = mock.MagicMock() +mockModule.isStarted = mock.Mock(return_value=False) +mockModule.PyJPClass = TypeMock("PyJPClass") +sys.modules['_jpype']=mockModule # For some reason jpype.imports does not work if called in sphinx. Importing # it here solved the problem. import jpype import jpype.imports - -import jpype -# TODO: reconsider this -#import jpype.imports - -#import java.lang -#import java.util -#import java.io version = jpype.__version__ # The full version, including alpha/beta/rc tags. release = jpype.__version__