Skip to content

#865: Restore part of the previous behavior on the suggested mocking-out... #868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,22 @@ This happens because our build system doesn't have the dependencies for building
You can mock out the imports for these modules in your ``conf.py`` with the following snippet::

import sys
from unittest.mock import MagicMock as Mock
from unittest.mock import MagicMock

class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return Mock()

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

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

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

from mock import Mock
from mock import Mock as MagicMock


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