Skip to content

Commit c5408f2

Browse files
committed
Merge pull request #868 from ankostis/master
#865: Restore part of the previous behavior on the suggested mocking-out...
2 parents 3b80e72 + 29553cd commit c5408f2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/faq.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,22 @@ This happens because our build system doesn't have the dependencies for building
3737
You can mock out the imports for these modules in your ``conf.py`` with the following snippet::
3838

3939
import sys
40-
from unittest.mock import MagicMock as Mock
40+
from unittest.mock import MagicMock
41+
42+
class Mock(MagicMock):
43+
@classmethod
44+
def __getattr__(cls, name):
45+
return Mock()
4146

4247
MOCK_MODULES = ['pygtk', 'gtk', 'gobject', 'argparse', 'numpy', 'pandas']
4348
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
4449

4550
Of course, replacing `MOCK_MODULES` with the modules that you want to mock out.
4651

4752
.. Tip:: The library ``unittest.mock`` was introduced on python 3.3. On earlier versions install the ``mock`` library
48-
from PyPI with (ie ``pip install mock``) and replace the above import with::
53+
from PyPI with (ie ``pip install mock``) and replace the above import::
4954

50-
from mock import Mock
55+
from mock import Mock as MagicMock
5156

5257

5358
Can I make search engines only see one version of my docs?

0 commit comments

Comments
 (0)