Esempio n. 1
0
def test_update(
    capsys, tmp_path, shared_datadir, source_pipfile_dirname, update_count
):  # type: (Any, Path, Path, str, int) -> None
    """
    test updating setup.py (when it already exists)
    """
    pipfile_dir = shared_datadir / source_pipfile_dirname
    for filename in ("Pipfile", "Pipfile.lock", "setup.py"):
        copy_file(pipfile_dir / filename, tmp_path)
    with data(source_pipfile_dirname, tmp_path):
        cmd(argv=["", "sync"])
        generated_setup = Path("setup.py")
        assert generated_setup.exists()
        generated_setup_text = generated_setup.read_text()
        expected_setup_text = Path("setup.py").read_text()
    for kw_arg_names in ("install_requires", "dependency_links"):

        assert compare_list_of_string_kw_arg(
            generated_setup_text,
            expected_setup_text,
            kw_arg_names,
            ordering_matters=False,
        )
    captured = capsys.readouterr()
    assert msg_formatter.update_success(update_count) in captured.out
Esempio n. 2
0
def test_sync_pipfile_but_lockfile_missing(tmp_path):
    """
    expected behavior:
    if the user uses `pipenv-setup sync --pipfile`, the absence of a lockfile should not fail the command
    """
    with data("missing_lockfile_0", tmp_path) as path:
        cmd(["", "sync", "--pipfile"])
Esempio n. 3
0
def test_only_setup_missing(
    capsys, tmp_path, shared_datadir, source_pipfile_dirname, update_count
):  # type: (Any, Path, Path, str, int) -> None
    """
    test generate setup.py (when it is missing)
    """
    pipfile_dir = shared_datadir / source_pipfile_dirname
    with data(source_pipfile_dirname, tmp_path):
        # delete the setup.py file that was copied to the tmp_path
        (tmp_path / "setup.py").unlink()
        cmd(argv=["", "sync"])
        generated_setup = Path("setup.py")
        assert generated_setup.exists()
        generated_setup_text = generated_setup.read_text()
        expected_setup_text = Path("setup.py").read_text()
    for kw_arg_names in ("install_requires", "dependency_links"):

        assert compare_list_of_string_kw_arg(
            generated_setup_text,
            expected_setup_text,
            kw_arg_names,
            ordering_matters=False,
        )
    captured = capsys.readouterr()
    assert msg_formatter.generate_success(update_count) in captured.out, captured.out
Esempio n. 4
0
def test_generation(tmp_path, shared_datadir,
                    source_pipfile_dirname):  # type: (Path, Path, str) -> None
    """
    test boilerplate
    """
    pipfile_dir = shared_datadir / source_pipfile_dirname
    copy_pipfiles(pipfile_dir, tmp_path)
    with data(source_pipfile_dirname, tmp_path):

        cmd(argv=["", "sync"])
        generated_setup = Path("setup.py")
        assert generated_setup.exists()
        generated_setup_text = generated_setup.read_text()
        expected_setup_text = Path("setup.py").read_text()
        for kw_arg_names in ("install_requires", "dependency_links"):

            assert compare_list_of_string_kw_arg(
                generated_setup_text,
                expected_setup_text,
                kw_arg_names,
                ordering_matters=False,
            )