Skip to content
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

Fix incorrect reraise #4566

Merged
merged 4 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion readthedocs/doc_builder/backends/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ def append_conf(self, **__):
except (ProjectConfigurationError, IOError):
trace = sys.exc_info()[2]
six.reraise(
ProjectConfigurationError,
ProjectConfigurationError(
ProjectConfigurationError.NOT_FOUND
),
None,
trace
)

Expand Down
32 changes: 31 additions & 1 deletion readthedocs/rtd_tests/tests/test_doc_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import tempfile
from collections import namedtuple

import mock
import py
import pytest
import yaml
import mock
from django.test import TestCase
from django.test.utils import override_settings
from django_dynamic_fixture import get
Expand Down Expand Up @@ -76,6 +77,35 @@ def test_create_conf_py(self, conf_file, get_conf_py_path, _, get_config_params,
with open(generated_conf_py) as gf, open(expected_conf_py) as ef:
self.assertEqual(gf.read(), ef.read())

@patch(
'readthedocs.doc_builder.backends.sphinx.SPHINX_TEMPLATE_DIR',
'/tmp/sphinx-template-dir',
)
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.docs_dir')
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.create_index')
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.get_config_params')
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.run')
@patch('readthedocs.builds.models.Version.get_conf_py_path')
def test_create_conf_py(
self, get_conf_py_path, _, get_config_params,
create_index, docs_dir):
"""
Test for a project with multiple ``conf.py`` files.

An error should be raised to the user if we can't
guess the correct conf.py file.
"""

tmp_docs_dir = py.path.local(tempfile.mkdtemp())
tmp_docs_dir.join('conf.py').new()
tmp_docs_dir.join('test').mkdir().join('conf.py').new()
docs_dir.return_value = str(tmp_docs_dir)
create_index.return_value = 'README.rst'
get_config_params.return_value = {}
get_conf_py_path.side_effect = ProjectConfigurationError
with pytest.raises(ProjectConfigurationError):
self.base_sphinx.append_conf()


@override_settings(PRODUCTION_DOMAIN='readthedocs.org')
class MkdocsBuilderTest(TestCase):
Expand Down