Exemple #1
0
def _output(version_info, lang):
    if lang == "cpp":
        return versioninfooutputter.to_cpp(version_info)
    elif lang == "python":
        return versioninfooutputter.to_python(version_info)
    else:
        raise ValueError("Unknown language")
    def test_output_python(self):
        expected = """
                # ---------------------------------------------------
                # This file is autogenerated by git-version.
                # DO NOT MODIFY!
                # ---------------------------------------------------

                VERSION_STRING = "versiontwo.dev2+rev230a"
                GIT_TAG_NAME = "versiontwo"
                GIT_COMMITS_SINCE_TAG = 2
                GIT_COMMIT_ID = "230a"
                MODIFIED_SINCE_COMMIT = False
                IS_DEV_VERSION = True
            """
        actual = versioninfooutputter.to_python(versioninfo.VersionInfo("versiontwo", 2, "230a", True, False))
        self.assertCodeEqual(expected, actual)
    def test_output_python(self):
        expected = """
                # ---------------------------------------------------
                # This file is autogenerated by git-version.
                # DO NOT MODIFY!
                # ---------------------------------------------------

                VERSION_STRING = "versiontwo.dev2+rev230a"
                GIT_TAG_NAME = "versiontwo"
                GIT_COMMITS_SINCE_TAG = 2
                GIT_COMMIT_ID = "230a"
                MODIFIED_SINCE_COMMIT = False
                IS_DEV_VERSION = True
            """
        actual = versioninfooutputter.to_python(
            versioninfo.VersionInfo("versiontwo", 2, "230a", True, False))
        self.assertCodeEqual(expected, actual)
    def test_output_python_modified(self):
        expected = """
                # ---------------------------------------------------
                # This file is autogenerated by git-version.
                # DO NOT MODIFY!
                # ---------------------------------------------------

                VERSION_STRING = "v1.0-stable-modified"
                GIT_TAG_NAME = "v1.0-stable"
                GIT_COMMITS_SINCE_TAG = 0
                GIT_COMMIT_ID = "230a"
                MODIFIED_SINCE_COMMIT = True
                IS_DEV_VERSION = True
                IS_STABLE_VERSION = False

                VERSION_COMPONENTS = ["1", "0"]
                VERSION_TAG = "stable"
            """
        actual = versioninfooutputter.to_python(versioninfo.VersionInfo("v1.0-stable", 0, "230a", True, True))
        self.assertCodeEqual(expected, actual)
    def test_output_python_with_version_info_and_version_tag(self):
        expected = """
                # ---------------------------------------------------
                # This file is autogenerated by git-version.
                # DO NOT MODIFY!
                # ---------------------------------------------------

                VERSION_STRING = "v1.0alpha.dev2+rev230a"
                GIT_TAG_NAME = "v1.0alpha"
                GIT_COMMITS_SINCE_TAG = 2
                GIT_COMMIT_ID = "230a"
                MODIFIED_SINCE_COMMIT = False
                IS_DEV_VERSION = True
                IS_STABLE_VERSION = False

                VERSION_COMPONENTS = ["1", "0"]
                VERSION_TAG = "alpha"
            """
        actual = versioninfooutputter.to_python(versioninfo.VersionInfo("v1.0alpha", 2, "230a", True, False))
        self.assertCodeEqual(expected, actual)
    def test_output_python_modified(self):
        expected = """
                # ---------------------------------------------------
                # This file is autogenerated by git-version.
                # DO NOT MODIFY!
                # ---------------------------------------------------

                VERSION_STRING = "v1.0-stable-modified"
                GIT_TAG_NAME = "v1.0-stable"
                GIT_COMMITS_SINCE_TAG = 0
                GIT_COMMIT_ID = "230a"
                MODIFIED_SINCE_COMMIT = True
                IS_DEV_VERSION = True
                IS_STABLE_VERSION = False

                VERSION_COMPONENTS = ["1", "0"]
                VERSION_TAG = "stable"
            """
        actual = versioninfooutputter.to_python(
            versioninfo.VersionInfo("v1.0-stable", 0, "230a", True, True))
        self.assertCodeEqual(expected, actual)
    def test_output_python_with_version_info_and_version_tag(self):
        expected = """
                # ---------------------------------------------------
                # This file is autogenerated by git-version.
                # DO NOT MODIFY!
                # ---------------------------------------------------

                VERSION_STRING = "v1.0alpha.dev2+rev230a"
                GIT_TAG_NAME = "v1.0alpha"
                GIT_COMMITS_SINCE_TAG = 2
                GIT_COMMIT_ID = "230a"
                MODIFIED_SINCE_COMMIT = False
                IS_DEV_VERSION = True
                IS_STABLE_VERSION = False

                VERSION_COMPONENTS = ["1", "0"]
                VERSION_TAG = "alpha"
            """
        actual = versioninfooutputter.to_python(
            versioninfo.VersionInfo("v1.0alpha", 2, "230a", True, False))
        self.assertCodeEqual(expected, actual)