How to use the johnnydep.lib.flatten_deps function in johnnydep

To help you get started, we’ve selected a few johnnydep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wimglenn / johnnydep / tests / test_lib.py View on Github external
def test_diamond_dependency_resolution(make_dist):
    make_dist(name="dist1", install_requires=["dist2a", "dist2b"])
    make_dist(name="dist2a", install_requires=["dist3[y]>0.2"])
    make_dist(name="dist2b", install_requires=["dist3[x,z]<0.4"])
    make_dist(name="dist3", version="0.2")
    make_dist(name="dist3", version="0.3")
    make_dist(name="dist3", version="0.4")
    jdist = JohnnyDist("dist1")
    dist1, dist2a, dist2b, dist3 = flatten_deps(jdist)

    assert dist1 is jdist
    assert dist1.requires == ["dist2a", "dist2b"]
    assert dist1.required_by == []

    assert dist2a.name == "dist2a"
    assert dist2a.requires == ["dist3[y]>0.2"]
    assert dist2a.required_by == ["dist1"]

    assert dist2b.name == "dist2b"
    assert dist2b.requires == ["dist3[x,z]<0.4"]
    assert dist2b.required_by == ["dist1"]

    assert dist3.name == "dist3"
    assert dist3.required_by == ["dist2a", "dist2b"]
    assert dist3.extras_requested == ["x", "y", "z"]  # merged
github wimglenn / johnnydep / tests / test_lib.py View on Github external
def test_resolve_unresolvable(make_dist):
    make_dist(
        name="dist1", description="unresolvable", install_requires=["dist2<=0.1", "dist2>0.2"]
    )
    make_dist(name="dist2", version="0.1")
    make_dist(name="dist2", version="0.3")
    dist = JohnnyDist("dist1")
    data = dist.serialise(recurse=False, fields=["project_name", "summary", "requires"])
    assert data == [
        {
            "project_name": "dist1",
            "summary": "unresolvable",
            "requires": ["dist2<=0.1", "dist2>0.2"],
        }
    ]
    gen = flatten_deps(dist)
    assert next(gen) is dist
    with pytest.raises(CalledProcessError) as cm:
        next(gen)
    msg = "DistributionNotFound: No matching distribution found for dist2<=0.1,>0.2\n"
    assert cm.value.output.decode().endswith(msg)
github wimglenn / johnnydep / tests / test_lib.py View on Github external
def test_flatten_dist_with_deps(make_dist):
    make_dist(name="root", install_requires=["dep"])
    make_dist(name="dep")
    jdist = JohnnyDist("root")
    reqs = list(flatten_deps(jdist))
    [dist0, dist1] = reqs
    assert dist0 is jdist
    assert dist1.name == "dep"
github wimglenn / johnnydep / tests / test_lib.py View on Github external
def test_flatten_dist_with_nodeps(make_dist):
    make_dist()
    jdist = JohnnyDist("jdtest")
    reqs = list(flatten_deps(jdist))
    assert reqs == [jdist]