1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
"""Check the docstring parsing."""
import io
from fades import parsing, REPO_PYPI, REPO_VCS
from tests import get_reqs
def test_empty():
parsed = parsing._parse_docstring(
io.StringIO("""
""")
)
assert parsed == {}
def test_only_comment():
with open("tests/test_files/no_req.py") as f:
parsed = parsing._parse_docstring(f)
assert parsed == {}
def test_req_in_module_docstring_triple_doublequoute():
with open("tests/test_files/req_module.py") as f:
parsed = parsing._parse_docstring(f)
assert parsed == {REPO_PYPI: get_reqs("foo", "bar")}
def test_req_in_module_docstring_triple_singlequote():
with open("tests/test_files/req_module_2.py") as f:
parsed = parsing._parse_docstring(f)
assert parsed == {REPO_PYPI: get_reqs("foo", "bar")}
def test_req_in_module_docstring_one_doublequote():
with open("tests/test_files/req_module_3.py") as f:
parsed = parsing._parse_docstring(f)
assert parsed == {}
def test_req_in_class_docstring():
with open("tests/test_files/req_class.py") as f:
parsed = parsing._parse_docstring(f)
# no requirements found
assert parsed == {}
def test_req_in_def_docstring():
with open("tests/test_files/req_def.py") as f:
parsed = parsing._parse_docstring(f)
# no requirements found
assert parsed == {}
def test_req_in_multi_docstring():
with open("tests/test_files/req_all.py") as f:
parsed = parsing._parse_docstring(f)
# Only module requirements was found
assert parsed == {REPO_PYPI: get_reqs("foo==1.4")}
def test_fades_word_as_part_of_text():
with open("tests/test_files/fades_as_part_of_other_word.py") as f:
parsed = parsing._parse_docstring(f)
assert parsed == {}
def test_mixed_backends():
with open("tests/test_files/req_mixed_backends.py") as f:
parsed = parsing._parse_docstring(f)
# Only module requirements was found
assert parsed == {
REPO_PYPI: get_reqs("foo", "bar"),
REPO_VCS: [
parsing.VCSDependency("git+http://whatever"),
parsing.VCSDependency("anotherurl"),
],
}
|