-
-
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 3 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 |
---|---|---|
@@ -1,77 +1,26 @@ | ||
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')) | ||
paths = str(find_one(os.getcwd(), r'readthedocs.yml')) | ||
assert len(paths) == 0 | ||
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. We need to change this to test that |
||
|
||
|
||
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')), | ||
} | ||
paths = find_one(base, r'readthedocs\.yml') | ||
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. paths -> path |
||
assert paths == str(os.path.abspath(os.path.join(base, 'readthedocs.yml'))) | ||
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 don't think we need str here |
||
|
||
|
||
@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.
I think we only need the asbpath of filename, no need to join it with _path or just join _path and filename (path is already an absolute path).