Skip to content

Commit f97b778

Browse files
committed
Move mock code to beginning of conf.py
1 parent fbd61a5 commit f97b778

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

doc/conf.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@
1616
import sys
1717
import os
1818

19+
# -- Mock module for _sane
20+
try:
21+
try:
22+
# Python >= 3.3
23+
from unittest.mock import MagicMock
24+
except:
25+
try:
26+
# Python < 3.3
27+
from mock import Mock as MagicMock
28+
except:
29+
raise ImportError
30+
31+
class Mock(MagicMock):
32+
@classmethod
33+
def __getattr__(cls, name):
34+
return Mock()
35+
36+
sys.modules.update([('_sane', Mock())])
37+
except:
38+
pass
39+
40+
1941
# If extensions (or modules to document with autodoc) are in another directory,
2042
# add these directories to sys.path here. If the directory is relative to the
2143
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -262,24 +284,3 @@
262284

263285
# If true, do not generate a @detailmenu in the "Top" node's menu.
264286
#texinfo_no_detailmenu = False
265-
266-
# -- Mock modules for readthedocs
267-
try:
268-
try:
269-
# Python >= 3.3
270-
from unittest.mock import MagicMock
271-
except:
272-
try:
273-
# Python < 3.3
274-
from mock import Mock as MagicMock
275-
except:
276-
raise ImportError
277-
278-
class Mock(MagicMock):
279-
@classmethod
280-
def __getattr__(cls, name):
281-
return Mock()
282-
283-
sys.modules.update([('_sane', Mock())])
284-
except:
285-
pass

0 commit comments

Comments
 (0)