]> git.notmuchmail.org Git - notmuch/commitdiff
python: fix documentation build with python 3.7
authorJani Nikula <jani.nikula@intel.com>
Mon, 11 Feb 2019 18:22:35 +0000 (20:22 +0200)
committerDavid Bremner <david@tethera.net>
Sat, 16 Feb 2019 12:42:13 +0000 (08:42 -0400)
The simplistic mocking in conf.py falls short on python 3.7. Just use
unittest.mock instead.

Fixes:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sphinx/config.py", line 368, in eval_config_file
    execfile_(filename, namespace)
  File "/usr/lib/python3/dist-packages/sphinx/util/pycompat.py", line 150, in execfile_
    exec_(code, _globals)
  File "/path/to/notmuch/bindings/python/docs/source/conf.py", line 39, in <module>
    from notmuch import __VERSION__,__AUTHOR__
  File "/path/to/notmuch/bindings/python/notmuch/__init__.py", line 54, in <module>
    from .database import Database
  File "/path/to/notmuch/bindings/python/notmuch/database.py", line 25, in <module>
    from .globals import (
  File "/path/to/notmuch/bindings/python/notmuch/globals.py", line 48, in <module>
    class NotmuchDatabaseS(Structure):
TypeError: __mro_entries__ must return a tuple

bindings/python/docs/source/conf.py

index 5b901c4ec4d82e18ed3a406a8dd7915e34668422..8b43c5ca3f9f1d019c49bf2ac3146186e14c828a 100644 (file)
 
 import sys, os
 
+from unittest.mock import Mock
+
 # If extensions (or modules to document with autodoc) are in another directory,
 # 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.
 sys.path.insert(0,os.path.abspath('../..'))
 
-class Mock(object):
-    def __init__(self, *args, **kwargs):
-        pass
-
-    def __call__(self, *args, **kwargs):
-        return Mock()
-
-    @classmethod
-    def __getattr__(self, name):
-        return Mock() if name not in ('__file__', '__path__') else '/dev/null'
-
 MOCK_MODULES = [
     'ctypes',
 ]