Skip to content

Commit dcb4270

Browse files
humitosagjohnson
authored andcommitted
Add start and termination to YAML file regex (#4584)
* Add start and termination to YAML file regex Otherwise it found files like: .hg/store/data/readthedocs.yml.i * Update common submodule * Tests (#4587)
1 parent b6bd7a6 commit dcb4270

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

common

readthedocs/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232

3333
ALL = 'all'
34-
CONFIG_FILENAME_REGEX = r'\.?readthedocs.ya?ml'
34+
CONFIG_FILENAME_REGEX = r'^\.?readthedocs.ya?ml$'
3535

3636
CONFIG_NOT_SUPPORTED = 'config-not-supported'
3737
VERSION_INVALID = 'version-invalid'

readthedocs/config/tests/test_config.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from __future__ import division, print_function, unicode_literals
33

44
import os
5-
import textwrap
65
import re
6+
import textwrap
77

88
import pytest
99
from mock import DEFAULT, patch
@@ -13,8 +13,8 @@
1313
ALL, BuildConfigV1, BuildConfigV2, ConfigError,
1414
ConfigOptionNotSupportedError, InvalidConfig, ProjectConfig, load)
1515
from readthedocs.config.config import (
16-
CONFIG_NOT_SUPPORTED, NAME_INVALID, NAME_REQUIRED, PYTHON_INVALID,
17-
VERSION_INVALID, CONFIG_FILENAME_REGEX)
16+
CONFIG_FILENAME_REGEX, CONFIG_NOT_SUPPORTED, CONFIG_REQUIRED, NAME_INVALID,
17+
NAME_REQUIRED, PYTHON_INVALID, VERSION_INVALID)
1818
from readthedocs.config.models import Conda
1919
from readthedocs.config.validation import (
2020
INVALID_BOOL, INVALID_CHOICE, INVALID_LIST, INVALID_PATH, INVALID_STRING)
@@ -81,10 +81,20 @@ def get_env_config(extra=None):
8181
return defaults
8282

8383

84-
def test_load_no_config_file(tmpdir):
84+
@pytest.mark.parametrize('files', [
85+
{},
86+
{'readthedocs.ymlmore': ''},
87+
{'startreadthedocs.yml': ''},
88+
{'noroot': {'readthedocs.ymlmore': ''}},
89+
{'noroot': {'startreadthedocs.yml': ''}},
90+
{'readthebots.yaml': ''},
91+
])
92+
def test_load_no_config_file(tmpdir, files):
93+
apply_fs(tmpdir, files)
8594
base = str(tmpdir)
86-
with raises(ConfigError):
95+
with raises(ConfigError) as e:
8796
load(base, env_config)
97+
assert e.value.code == CONFIG_REQUIRED
8898

8999

90100
def test_load_empty_config_file(tmpdir):

0 commit comments

Comments
 (0)