Beispiel #1
0
def test_version_not_changed(temp_dir):
    with temp_dir.as_cwd():
        assert not isfile(temp_dir.join("fakekeats/__version__.py"))
        # Should not fail with default
        keats = Keats()
        keats.version.up()
        assert isfile(temp_dir.join("fakekeats/__version__.py"))

        cmd_output("git", "add", "pyproject.toml")
        assert main(argv=["pyproject.toml"]) == 0
Beispiel #2
0
def test_version_no_change(temp_dir, line):
    """Expect no change with just reformatting or comments."""
    with temp_dir.as_cwd():
        assert not isfile(temp_dir.join("fakekeats/__version__.py"))
        # Should not fail with default
        keats = Keats()
        keats.version.up()
        assert isfile(temp_dir.join("fakekeats/__version__.py"))

        with open(temp_dir.join("fakekeats/__version__.py"), "a") as f:
            f.writelines([line])

        cmd_output("git", "add", "pyproject.toml")
        assert main(argv=["pyproject.toml"]) == 0
Beispiel #3
0
def test_update_pyproject(temp_dir):
    with temp_dir.as_cwd():
        assert not isfile(temp_dir.join("fakekeats/__version__.py"))
        # Should not fail with default
        keats = Keats()
        keats.version.up()
        assert isfile(temp_dir.join("fakekeats/__version__.py"))

        import toml

        with open("pyproject.toml", "r") as f:
            config = toml.load(f)

        config["tool"]["poetry"]["version"] = "1.0.0"
        with open("pyproject.toml", "w") as f:
            toml.dump(config, f)

        cmd_output("git", "add", "pyproject.toml")
        assert main(argv=["pyproject.toml"]) == 1

        with open("fakekeats/__version__.py", "r") as f:
            txt = f.read()
            assert '__version__ = "1.0.0"' in txt or "__version__ = '1.0.0'" in txt
Beispiel #4
0
def run(filenames):
    retv = 0
    trigger_files = {PYPROJECT}
    _added_files = added_files()
    files = _added_files & set(filenames)
    triggered_files = trigger_files.intersection(files)

    logger.debug("Added files: {}".format(_added_files))
    logger.debug("Pre-commit files: {}".format(set(filenames)))
    logger.debug("Trigger files: {}".format(trigger_files))
    logger.debug("Triggered files: {}".format(triggered_files))

    if triggered_files:
        keats = Keats()
        keats.version.up()
        retv = 1
    else:
        logger.debug("No changes to be made.")
    # else:
    #     keats = Keats()
    #     if not keats.version._exists():
    #         keats.version.up()
    return retv
Beispiel #5
0
def fake_keats(fake_project):
    return Keats(fake_project)
Beispiel #6
0
def test_no_pyproject_toml(tmpdir):
    tmpdir.mkdir("testpackage")
    with pytest.raises(FileNotFoundError):
        Keats()
Beispiel #7
0
def version_up():
    logger.debug("initializing Keats() at {}".format(os.getcwd()))
    keats = Keats()
    logger.info("__version__.py at {}".format(
        keats.version._get_version_path()))
    keats.version.up()