Exemple #1
0
def test_repo_line(repo_line):
    reformatted_line = repo_line
    if repo_line.startswith("-e "):
        repo_list = repo_line.split(" ", 1)
        if "; " in repo_list[1]:
            reformatted_line = '{0} "{1}"'.format(repo_list[0], repo_list[1])
    else:
        repo_list = [repo_line]
    line_as_list = repo_line.split(
        " ", 1) if repo_line.startswith("-e ") else [repo_line]
    assert (Line(repo_line).get_line(with_prefix=True,
                                     with_markers=True,
                                     as_list=False) == reformatted_line)
    assert (Line(repo_line).get_line(with_prefix=True,
                                     with_markers=True,
                                     as_list=True) == repo_list)
Exemple #2
0
def test_convert_from_pip(monkeypatch, expected, requirement):
    with monkeypatch.context() as m:
        m.setattr(Requirement, "run_requires", mock_run_requires)
        m.setattr(SetupInfo, "get_info", mock_run_requires)
        m.setattr(Line, "get_setup_info", mock_run_requires)
        m.setattr(pip_shims.shims, "unpack_url", mock_unpack)
        pkg_name = next(iter(expected.keys()))
        pkg_pipfile = expected[pkg_name]
        line = Line(requirement)
        if (hasattr(pkg_pipfile, "keys") and "editable" in pkg_pipfile
                and not pkg_pipfile["editable"]):
            del expected[pkg_name]["editable"]
        req = Requirement.from_line(requirement)
        assert req.as_pipfile() == expected
        assert line.line_with_prefix == req.as_line(include_hashes=False)
        assert hash(Line(line.line_with_prefix)) == hash(
            Line(line.line_with_prefix))
Exemple #3
0
def test_requirement_line(req):
    line = Line(req.line)
    assert line.get_line(with_markers=True, with_hashes=True) == req.line
    assert line.get_line(with_markers=True, with_hashes=True,
                         as_list=True) == req.as_list
    assert line.get_line(with_markers=False,
                         with_hashes=True) == req.line_without_markers
    assert (line.get_line(with_markers=False, with_hashes=True,
                          as_list=True) == req.list_without_markers)