Skip to content

Commit 070c322

Browse files
authored
Merge pull request #4379 from stsewd/fix-base-path-config-v1
Set full `source_file` path for default configuration
2 parents bb3c353 + 2dbb2ad commit 070c322

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

readthedocs/doc_builder/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from __future__ import (
55
absolute_import, division, print_function, unicode_literals)
66

7+
from os import path
8+
79
from readthedocs.config import BuildConfig, ConfigError, InvalidConfig
810
from readthedocs.config import load as load_config
911

@@ -68,7 +70,7 @@ def load_yaml_config(version):
6870
config = BuildConfig(
6971
env_config=env_config,
7072
raw_config={},
71-
source_file='empty',
73+
source_file=path.join(checkout_path, 'empty'),
7274
source_position=0,
7375
)
7476
config.validate()

readthedocs/rtd_tests/tests/test_doc_building.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,10 @@ def assertArgsStartsWith(self, args, function_mock):
11531153
if arg is not mock.ANY:
11541154
self.assertTrue(arg_mock.startswith(arg))
11551155

1156-
def test_install_core_requirements_sphinx(self):
1156+
@patch('readthedocs.projects.models.Project.checkout_path')
1157+
def test_install_core_requirements_sphinx(self, checkout_path):
1158+
tmpdir = tempfile.mkdtemp()
1159+
checkout_path.return_value = tmpdir
11571160
python_env = Virtualenv(
11581161
version=self.version_sphinx,
11591162
build_env=self.build_env_mock,
@@ -1171,7 +1174,10 @@ def test_install_core_requirements_sphinx(self):
11711174
self.build_env_mock.run.assert_called_once()
11721175
self.assertArgsStartsWith(args, self.build_env_mock.run)
11731176

1174-
def test_install_core_requirements_mkdocs(self):
1177+
@patch('readthedocs.projects.models.Project.checkout_path')
1178+
def test_install_core_requirements_mkdocs(self, checkout_path):
1179+
tmpdir = tempfile.mkdtemp()
1180+
checkout_path.return_value = tmpdir
11751181
python_env = Virtualenv(
11761182
version=self.version_mkdocs,
11771183
build_env=self.build_env_mock
@@ -1187,7 +1193,8 @@ def test_install_core_requirements_mkdocs(self):
11871193
self.build_env_mock.run.assert_called_once()
11881194
self.assertArgsStartsWith(args, self.build_env_mock.run)
11891195

1190-
def test_install_user_requirements(self):
1196+
@patch('readthedocs.projects.models.Project.checkout_path')
1197+
def test_install_user_requirements(self, checkout_path):
11911198
"""
11921199
If a projects does not specify a requirements file,
11931200
RTD will choose one automatically.
@@ -1198,6 +1205,8 @@ def test_install_user_requirements(self):
11981205
- ``pip_requirements.txt``
11991206
- ``requirements.txt``
12001207
"""
1208+
tmpdir = tempfile.mkdtemp()
1209+
checkout_path.return_value = tmpdir
12011210
self.build_env_mock.project = self.project_sphinx
12021211
self.build_env_mock.version = self.version_sphinx
12031212
python_env = Virtualenv(
@@ -1267,7 +1276,10 @@ def test_install_user_requirements(self):
12671276
python_env.install_user_requirements()
12681277
self.build_env_mock.run.assert_not_called()
12691278

1270-
def test_install_core_requirements_sphinx_conda(self):
1279+
@patch('readthedocs.projects.models.Project.checkout_path')
1280+
def test_install_core_requirements_sphinx_conda(self, checkout_path):
1281+
tmpdir = tempfile.mkdtemp()
1282+
checkout_path.return_value = tmpdir
12711283
python_env = Conda(
12721284
version=self.version_sphinx,
12731285
build_env=self.build_env_mock,
@@ -1307,7 +1319,10 @@ def test_install_core_requirements_sphinx_conda(self):
13071319
mock.call(*args_pip, bin_path=mock.ANY)
13081320
])
13091321

1310-
def test_install_core_requirements_mkdocs_conda(self):
1322+
@patch('readthedocs.projects.models.Project.checkout_path')
1323+
def test_install_core_requirements_mkdocs_conda(self, checkout_path):
1324+
tmpdir = tempfile.mkdtemp()
1325+
checkout_path.return_value = tmpdir
13111326
python_env = Conda(
13121327
version=self.version_mkdocs,
13131328
build_env=self.build_env_mock,
@@ -1343,7 +1358,10 @@ def test_install_core_requirements_mkdocs_conda(self):
13431358
mock.call(*args_pip, bin_path=mock.ANY)
13441359
])
13451360

1346-
def test_install_user_requirements_conda(self):
1361+
@patch('readthedocs.projects.models.Project.checkout_path')
1362+
def test_install_user_requirements_conda(self, checkout_path):
1363+
tmpdir = tempfile.mkdtemp()
1364+
checkout_path.return_value = tmpdir
13471365
python_env = Conda(
13481366
version=self.version_sphinx,
13491367
build_env=self.build_env_mock,

0 commit comments

Comments
 (0)