示例#1
0
def test_snapshot_with_version_file():
    with setupmeta.temp_resource() as temp:
        with conftest.capture_output() as logged:
            with open(os.path.join(temp, setupmeta.VERSION_FILE), "w") as fh:
                fh.write("v1.2.3-4-g1234567")

            setup_py = os.path.join(temp, "setup.py")
            meta = SetupMeta().finalize(
                dict(_setup_py_path=setup_py,
                     name="just-testing",
                     versioning="post",
                     setup_requires="setupmeta"))

            versioning = meta.versioning
            assert meta.version == "1.2.3.post4"
            assert not versioning.generate_version_file
            assert versioning.scm.program is None
            assert str(versioning.scm).startswith("snapshot ")
            assert not versioning.scm.is_dirty()
            assert versioning.scm.get_branch() == "HEAD"

            # Trigger artificial rewriting of version file
            versioning.generate_version_file = True
            versioning.auto_fill_version()
            assert "WARNING: No 'packages' or 'py_modules' defined" in logged
示例#2
0
def test_snapshot_with_version_file():
    with setupmeta.temp_resource() as temp:
        with open(os.path.join(temp, setupmeta.VERSION_FILE), "w") as fh:
            fh.write("v1.2.3-4-g1234567")

        setup_py = os.path.join(temp, "setup.py")
        meta = SetupMeta(dict(_setup_py_path=setup_py, versioning="post", setup_requires="setupmeta"))

        versioning = meta.versioning
        assert meta.version == "1.2.3.post4"
        assert not versioning.generate_version_file
        assert versioning.scm.program is None
        assert str(versioning.scm).startswith("snapshot ")
        assert not versioning.scm.is_dirty()
        assert versioning.scm.get_branch() == "HEAD"

        # Trigger artificial rewriting of version file
        versioning.generate_version_file = True
        versioning.auto_fill_version()
示例#3
0
def test_snapshot():
    temp = tempfile.mkdtemp()
    try:
        with open(os.path.join(temp, setupmeta.VERSION_FILE), 'w') as fh:
            fh.write('v1.2.3-4-g1234567')

        setup_py = os.path.join(temp, 'setup.py')
        meta = SetupMeta(dict(_setup_py_path=setup_py, versioning='post', setup_requires='setupmeta'))
        versioning = meta.versioning
        assert meta.version == '1.2.3.post4'
        assert not versioning.generate_version_file

        assert versioning.scm.program is None
        assert str(versioning.scm).startswith('snapshot ')
        assert not versioning.scm.is_dirty()
        assert versioning.scm.get_branch() == 'HEAD'

        # Trigger artificial rewriting of version file
        versioning.generate_version_file = True
        versioning.auto_fill_version()

    finally:
        shutil.rmtree(temp)