Skip to content

Commit

Permalink
Workaround for conflict of unittest with metaclass. mock manually
Browse files Browse the repository at this point in the history
  • Loading branch information
israelmcmc committed Jan 23, 2024
1 parent 6d01784 commit 12cd14b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt install pandoc
pip install sphinx sphinx_rtd_theme nbsphinx
pip install sphinx sphinx_rtd_theme nbsphinx mock
- name: Sphinx build
run: |
make -C docs html
Expand Down
9 changes: 9 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@
'tqdm',
'scipy']

# There seems to be a conflict between unittest.mock (used by sphinx) and metaclasses
# The cosipy.threeml.custom_functions.Band_Eflux includes a metaclass from
# astromodels.functions.function, so we mock that one manually with the mock package
import mock

MOCK_MODULES = ['astromodels.functions.function']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()

# intersphinx for mocked dependencies

intersphinx_mapping = {
Expand Down
4 changes: 2 additions & 2 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ You can install ``pytest`` and ``pytest-cov`` with::
Compiling the docs
------------------

You need pandoc, sphinx, nbsphinx and sphinx_rtd_theme. Using conda::
You need pandoc, sphinx, nbsphinx, sphinx_rtd_theme and mock. Using conda::

conda install -c conda-forge pandoc nbsphinx sphinx_rtd_theme
conda install -c conda-forge pandoc nbsphinx sphinx_rtd_theme mock

Onece you have this requirements, run::

Expand Down

0 comments on commit 12cd14b

Please sign in to comment.