|
5 | 5 | * the Command wrappers encapsulate the bytes and expose unicode
|
6 | 6 | """
|
7 | 7 | import hashlib
|
| 8 | +from itertools import zip_longest |
8 | 9 | import json
|
9 | 10 | import os
|
10 | 11 | import tempfile
|
@@ -1210,8 +1211,9 @@ def assertArgsStartsWith(self, args, call):
|
1210 | 1211 | with each element of args.
|
1211 | 1212 | """
|
1212 | 1213 | args_mock, _ = call
|
1213 |
| - for arg, arg_mock in zip(args, args_mock): |
| 1214 | + for arg, arg_mock in zip_longest(args, args_mock): |
1214 | 1215 | if arg is not mock.ANY:
|
| 1216 | + self.assertIsNotNone(arg_mock) |
1215 | 1217 | self.assertTrue(arg_mock.startswith(arg))
|
1216 | 1218 |
|
1217 | 1219 | @patch('readthedocs.projects.models.Project.checkout_path')
|
@@ -1241,6 +1243,44 @@ def test_install_core_requirements_sphinx(self, checkout_path):
|
1241 | 1243 | args = self.pip_install_args + requirements
|
1242 | 1244 | self.assertArgsStartsWith(args, calls[1])
|
1243 | 1245 |
|
| 1246 | + @mock.patch('readthedocs.doc_builder.config.load_config') |
| 1247 | + @patch('readthedocs.projects.models.Project.checkout_path') |
| 1248 | + def test_install_core_requirements_sphinx_system_packages_caps_setuptools(self, checkout_path, load_config): |
| 1249 | + config_data = { |
| 1250 | + 'python': { |
| 1251 | + 'use_system_site_packages': True, |
| 1252 | + }, |
| 1253 | + } |
| 1254 | + load_config.side_effect = create_load(config_data) |
| 1255 | + config = load_yaml_config(self.version_sphinx) |
| 1256 | + |
| 1257 | + tmpdir = tempfile.mkdtemp() |
| 1258 | + checkout_path.return_value = tmpdir |
| 1259 | + python_env = Virtualenv( |
| 1260 | + version=self.version_sphinx, |
| 1261 | + build_env=self.build_env_mock, |
| 1262 | + config=config, |
| 1263 | + ) |
| 1264 | + python_env.install_core_requirements() |
| 1265 | + requirements_sphinx = [ |
| 1266 | + 'commonmark', |
| 1267 | + 'recommonmark', |
| 1268 | + 'sphinx', |
| 1269 | + 'sphinx-rtd-theme', |
| 1270 | + 'readthedocs-sphinx-ext', |
| 1271 | + 'setuptools<58.3.0', |
| 1272 | + ] |
| 1273 | + |
| 1274 | + self.assertEqual(self.build_env_mock.run.call_count, 2) |
| 1275 | + calls = self.build_env_mock.run.call_args_list |
| 1276 | + |
| 1277 | + core_args = self.pip_install_args + ['pip', 'setuptools<58.3.0'] |
| 1278 | + self.assertArgsStartsWith(core_args, calls[0]) |
| 1279 | + |
| 1280 | + requirements = self.base_requirements + requirements_sphinx |
| 1281 | + args = self.pip_install_args + ['-I'] + requirements |
| 1282 | + self.assertArgsStartsWith(args, calls[1]) |
| 1283 | + |
1244 | 1284 | @patch('readthedocs.projects.models.Project.checkout_path')
|
1245 | 1285 | def test_install_core_requirements_mkdocs(self, checkout_path):
|
1246 | 1286 | tmpdir = tempfile.mkdtemp()
|
|
0 commit comments