Skip to content

Commit fc5c6e5

Browse files
qwcodegvalkov
authored andcommitted
tests for: isolated mode, default vcs, ignoring comments, setting the finder, joining lines,
1 parent 12eab18 commit fc5c6e5

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

tests/unit/test_req_file.py

+37-7
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,12 @@ def test_option_with_no_value_raises(self):
154154
parse_line('--index-url')
155155

156156

157-
158157
class TestParseContent(object):
159158
"""tests for `parse_content`"""
160159

161-
# TODO
162-
# isolated mode
163-
# comments
164-
# finder options
165-
# join
166-
# comes_from
160+
def setup(self):
161+
self.options = stub(isolated_mode=False, default_vcs=None,
162+
skip_requirements_regex=False)
167163

168164
def test_parse_content_requirement(self):
169165
content = 'SomeProject'
@@ -193,6 +189,40 @@ def stub_parse_requirements(req_url, finder, comes_from, options,
193189
parse_requirements_stub.call)
194190
assert list(parse_content('filename', content)) == [req]
195191

192+
def test_parse_set_isolated(self):
193+
content = 'SomeProject'
194+
filename = 'filename'
195+
self.options.isolated_mode = True
196+
result = parse_content(filename, content, options=self.options)
197+
assert list(result)[0].isolated
198+
199+
def test_parse_set_default_vcs(self):
200+
url = 'https://url#egg=SomeProject'
201+
content = '-e %s' % url
202+
filename = 'filename'
203+
self.options.default_vcs = 'git'
204+
result = parse_content(filename, content, options=self.options)
205+
assert list(result)[0].link.url == 'git+' + url
206+
207+
def test_parse_set_finder(self):
208+
content = '--index-url url'
209+
filename = 'filename'
210+
finder = stub()
211+
list(parse_content(filename, content, finder=finder))
212+
assert finder.index_urls == ['url']
213+
214+
def test_parse_content_join_lines(self):
215+
content = '--index-url \\url'
216+
filename = 'filename'
217+
finder = stub()
218+
list(parse_content(filename, content, finder=finder))
219+
assert finder.index_urls == ['url']
220+
221+
def test_parse_content_ignore_comment(self):
222+
content = '# SomeProject'
223+
filename = 'filename'
224+
assert list(parse_content(filename, content)) == []
225+
196226

197227
@pytest.fixture
198228
def session():

0 commit comments

Comments
 (0)