-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Remove logic around finding a configuration file inside directories #4714
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
Changes from 5 commits
16aad41
95733b7
4c0a670
b1c5d48
ba58ea0
06ee692
3e0831e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,22 @@ def test_load_no_config_file(tmpdir, files): | |
base = str(tmpdir) | ||
with raises(ConfigError) as e: | ||
load(base, env_config) | ||
nested_files = { | ||
'first': { | ||
'readthedocs.yml': '', | ||
}, | ||
'second': { | ||
'confuser.txt': 'content', | ||
}, | ||
'third': { | ||
'readthedocs.yml': 'content', | ||
'Makefile': '', | ||
}, | ||
} | ||
apply_fs(tmpdir, nested_files) | ||
with raises(ConfigError) as e: | ||
load(base, env_config) | ||
|
||
assert e.value.code == CONFIG_REQUIRED | ||
|
||
|
||
|
@@ -275,7 +291,6 @@ def test_python_pip_install_default(): | |
|
||
|
||
def describe_validate_python_extra_requirements(): | ||
|
||
def it_defaults_to_list(): | ||
build = get_build_config({'python': {}}, get_env_config()) | ||
build.validate() | ||
|
@@ -309,7 +324,6 @@ def it_uses_validate_string(validate_string): | |
|
||
|
||
def describe_validate_use_system_site_packages(): | ||
|
||
def it_defaults_to_false(): | ||
build = get_build_config({'python': {}}, get_env_config()) | ||
build.validate() | ||
|
@@ -337,7 +351,6 @@ def it_uses_validate_bool(validate_bool): | |
|
||
|
||
def describe_validate_setup_py_install(): | ||
|
||
def it_defaults_to_false(): | ||
build = get_build_config({'python': {}}, get_env_config()) | ||
build.validate() | ||
|
@@ -365,7 +378,6 @@ def it_uses_validate_bool(validate_bool): | |
|
||
|
||
def describe_validate_python_version(): | ||
|
||
def it_defaults_to_a_valid_version(): | ||
build = get_build_config({'python': {}}, get_env_config()) | ||
build.validate() | ||
|
@@ -465,7 +477,6 @@ def it_respects_default_value(value): | |
|
||
|
||
def describe_validate_formats(): | ||
|
||
def it_defaults_to_empty(): | ||
build = get_build_config({}, get_env_config()) | ||
build.validate() | ||
|
@@ -545,7 +556,6 @@ def test_valid_build_config(): | |
|
||
|
||
def describe_validate_base(): | ||
|
||
def it_validates_to_abspath(tmpdir): | ||
apply_fs(tmpdir, {'configs': minimal_config, 'docs': {}}) | ||
with tmpdir.as_cwd(): | ||
|
@@ -597,7 +607,6 @@ def it_fails_if_base_does_not_exist(tmpdir): | |
|
||
|
||
def describe_validate_build(): | ||
|
||
def it_fails_if_build_is_invalid_option(tmpdir): | ||
apply_fs(tmpdir, minimal_config) | ||
build = BuildConfigV1( | ||
|
@@ -1089,12 +1098,12 @@ def test_python_requirements_default_value(self): | |
assert build.python.requirements is None | ||
|
||
def test_python_requirements_allow_null(self): | ||
build = self.get_build_config({'python': {'requirements': None}},) | ||
build = self.get_build_config({'python': {'requirements': None}}, ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These modifications don't seem to belong to this PR |
||
build.validate() | ||
assert build.python.requirements is None | ||
|
||
def test_python_requirements_allow_empty_string(self): | ||
build = self.get_build_config({'python': {'requirements': ''}},) | ||
build = self.get_build_config({'python': {'requirements': ''}}, ) | ||
build.validate() | ||
assert build.python.requirements == '' | ||
|
||
|
@@ -1120,13 +1129,13 @@ def test_python_requirements_priority_over_default(self, tmpdir): | |
|
||
@pytest.mark.parametrize('value', [3, [], {}]) | ||
def test_python_requirements_check_invalid_types(self, value): | ||
build = self.get_build_config({'python': {'requirements': value}},) | ||
build = self.get_build_config({'python': {'requirements': value}}, ) | ||
with raises(InvalidConfig) as excinfo: | ||
build.validate() | ||
assert excinfo.value.key == 'python.requirements' | ||
|
||
def test_python_install_pip_check_valid(self): | ||
build = self.get_build_config({'python': {'install': 'pip'}},) | ||
build = self.get_build_config({'python': {'install': 'pip'}}, ) | ||
build.validate() | ||
assert build.python.install_with_pip is True | ||
assert build.python.install_with_setup is False | ||
|
@@ -1141,7 +1150,7 @@ def test_python_install_pip_priority_over_default(self): | |
assert build.python.install_with_setup is False | ||
|
||
def test_python_install_setuppy_check_valid(self): | ||
build = self.get_build_config({'python': {'install': 'setup.py'}},) | ||
build = self.get_build_config({'python': {'install': 'setup.py'}}, ) | ||
build.validate() | ||
assert build.python.install_with_setup is True | ||
assert build.python.install_with_pip is False | ||
|
@@ -1166,13 +1175,13 @@ def test_python_install_setuppy_priority_over_default(self): | |
|
||
@pytest.mark.parametrize('value', ['invalid', 'apt']) | ||
def test_python_install_check_invalid(self, value): | ||
build = self.get_build_config({'python': {'install': value}},) | ||
build = self.get_build_config({'python': {'install': value}}, ) | ||
with raises(InvalidConfig) as excinfo: | ||
build.validate() | ||
assert excinfo.value.key == 'python.install' | ||
|
||
def test_python_install_allow_null(self): | ||
build = self.get_build_config({'python': {'install': None}},) | ||
build = self.get_build_config({'python': {'install': None}}, ) | ||
build.validate() | ||
assert build.python.install_with_pip is False | ||
assert build.python.install_with_setup is False | ||
|
@@ -1185,7 +1194,7 @@ def test_python_install_default(self): | |
|
||
@pytest.mark.parametrize('value', [2, [], {}]) | ||
def test_python_install_check_invalid_type(self, value): | ||
build = self.get_build_config({'python': {'install': value}},) | ||
build = self.get_build_config({'python': {'install': value}}, ) | ||
with raises(InvalidConfig) as excinfo: | ||
build.validate() | ||
assert excinfo.value.key == 'python.install' | ||
|
@@ -1379,7 +1388,7 @@ def test_sphinx_cant_be_used_with_mkdocs(self, tmpdir): | |
assert excinfo.value.key == '.' | ||
|
||
def test_sphinx_configuration_allow_null(self): | ||
build = self.get_build_config({'sphinx': {'configuration': None}},) | ||
build = self.get_build_config({'sphinx': {'configuration': None}}, ) | ||
build.validate() | ||
assert build.sphinx.configuration is None | ||
|
||
|
@@ -1420,7 +1429,7 @@ def test_sphinx_configuration_priorities_over_default(self, tmpdir): | |
|
||
@pytest.mark.parametrize('value', [[], True, 0, {}]) | ||
def test_sphinx_configuration_validate_type(self, value): | ||
build = self.get_build_config({'sphinx': {'configuration': value}},) | ||
build = self.get_build_config({'sphinx': {'configuration': value}}, ) | ||
with raises(InvalidConfig) as excinfo: | ||
build.validate() | ||
assert excinfo.value.key == 'sphinx.configuration' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,24 @@ | ||
from __future__ import division, print_function, unicode_literals | ||
|
||
import os | ||
|
||
import pytest | ||
import six | ||
|
||
from readthedocs.config.find import find_all, find_one | ||
from readthedocs.config.find import find_one | ||
|
||
from .utils import apply_fs | ||
|
||
|
||
def test_find_no_files(tmpdir): | ||
with tmpdir.as_cwd(): | ||
paths = list(find_all(os.getcwd(), r'readthedocs.yml')) | ||
assert len(paths) == 0 | ||
paths = str(find_one(os.getcwd(), r'readthedocs.yml')) | ||
assert paths == '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to call |
||
|
||
|
||
def test_find_at_root(tmpdir): | ||
apply_fs(tmpdir, {'readthedocs.yml': '', 'otherfile.txt': ''}) | ||
|
||
base = str(tmpdir) | ||
paths = list(find_all(base, r'readthedocs\.yml')) | ||
assert paths == [ | ||
os.path.abspath(os.path.join(base, 'readthedocs.yml')) | ||
] | ||
|
||
|
||
def test_find_nested(tmpdir): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd left this test to check that we are not finding nested files |
||
apply_fs(tmpdir, { | ||
'first': { | ||
'readthedocs.yml': '', | ||
}, | ||
'second': { | ||
'confuser.txt': 'content', | ||
}, | ||
'third': { | ||
'readthedocs.yml': 'content', | ||
'Makefile': '', | ||
}, | ||
}) | ||
apply_fs(tmpdir, {'first/readthedocs.yml': ''}) | ||
|
||
base = str(tmpdir) | ||
paths = set(find_all(base, r'readthedocs\.yml')) | ||
assert paths == { | ||
str(tmpdir.join('first', 'readthedocs.yml')), | ||
str(tmpdir.join('third', 'readthedocs.yml')), | ||
} | ||
|
||
|
||
def test_find_multiple_files(tmpdir): | ||
apply_fs(tmpdir, { | ||
'first': { | ||
'readthedocs.yml': '', | ||
'.readthedocs.yml': 'content', | ||
}, | ||
'second': { | ||
'confuser.txt': 'content', | ||
}, | ||
'third': { | ||
'readthedocs.yml': 'content', | ||
'Makefile': '', | ||
}, | ||
}) | ||
apply_fs(tmpdir, {'first/readthedocs.yml': ''}) | ||
|
||
base = str(tmpdir) | ||
paths = set(find_all(base, r'\.?readthedocs\.yml')) | ||
assert paths == { | ||
str(tmpdir.join('first', 'readthedocs.yml')), | ||
str(tmpdir.join('first', '.readthedocs.yml')), | ||
str(tmpdir.join('third', 'readthedocs.yml')), | ||
} | ||
path = find_one(base, r'readthedocs\.yml') | ||
assert path == os.path.abspath(os.path.join(base, 'readthedocs.yml')) | ||
|
||
|
||
@pytest.mark.skipif(not six.PY2, reason='Only for python2') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case should be moved to the decorator, not inside the function