How to use the requirementslib.models.lockfile.Lockfile function in requirementslib

To help you get started, we’ve selected a few requirementslib 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 sarugaku / requirementslib / tests / unit / test_lockfile.py View on Github external
def test_failure(pipfile_dir):
    pipfile_location = pipfile_dir / "Pipfile.both-sections"
    with pytest.raises(PipfileNotFound):
        Lockfile.lockfile_from_pipfile("some_fake_pipfile_path")
    with pytest.raises(MissingParameter):
        Lockfile.from_data(None, None)
    with pytest.raises(MissingParameter):
        Lockfile.from_data(pipfile_location.as_posix(), None)
    with pytest.raises(MissingParameter):
        Lockfile.from_data(None, {})
    with pytest.raises(TypeError):
        Lockfile.from_data(pipfile_location.as_posix(), True)
github sarugaku / requirementslib / tests / unit / test_lockfile.py View on Github external
def test_lockfile(tmpdir):
    with temp_environ():
        os.environ["PIPENV_CACHE_DIR"] = tmpdir.strpath
        lockfile = Lockfile.create(".")

        requires = lockfile.as_requirements(dev=False)
        assert requires == []

        requires = lockfile.as_requirements(dev=True)
        assert any(req.startswith("attrs") for req in requires)
github sarugaku / requirementslib / tests / unit / test_lockfile.py View on Github external
}
        }
    }
    """.strip()
        )
    )
    loaded = Lockfile.load(lockfile.as_posix())
    dump_to = pathlib_tmpdir.joinpath("new_lockfile")
    dump_to.mkdir()
    from_data = Lockfile.from_data(
        dump_to.as_posix(), json.loads(lockfile.read_text()), meta_from_project=False
    )
    assert isinstance(loaded.dev_requirements[0], Requirement)
    assert isinstance(loaded.dev_requirements_list[0], dict)
    with cd(pathlib_tmpdir.as_posix()):
        auto_detected_path = Lockfile()
        assert (
            auto_detected_path.path.absolute().as_posix()
            == lockfile.absolute().as_posix()
        )
        assert auto_detected_path["develop-editable"]["requests"] is not None