From b973e7aae10d4387c8e978c7a7a71dcfe77f59f4 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Wed, 19 Dec 2018 12:09:00 +0100 Subject: [PATCH] doc: Fix iterating over the Mock object in Python 3 Building the documentation for salt.modules.snapper fails with Python 3: ``` $ make -C doc html [...] WARNING: [autosummary] failed to import 'salt.modules.snapper': no module named salt.modules.snapper building [mo]: targets for 0 po files that are out of date building [html]: targets for 109 source files that are out of date updating environment: [config changed] 1608 added, 17 changed, 0 removed reading sources... [100%] topics/yaml/index doc/ref/modules/all/index.rst:20: WARNING: failed to import snapper doc/ref/modules/all/index.rst:20: WARNING: toctree references unknown document 'ref/modules/all/snapper' WARNING: autodoc: failed to import module 'salt.modules.snapper'; the following exception was raised: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 152, in import_module __import__(modname) File "salt/modules/snapper.py", line 72, in if SNAPPER_DBUS_OBJECT in bus.list_activatable_names(): TypeError: argument of type 'Mock' is not iterable ``` Fix the Mock object to be iterable (as it was intended to). Signed-off-by: Benjamin Drung --- doc/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 33f1eb180e..4fbc981a4a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -55,9 +55,12 @@ class Mock(object): def __iter__(self): return self - def next(self): + def __next__(self): raise StopIteration + # For Python 2 + next = __next__ + # pylint: enable=R0903 MOCK_MODULES = [