From eb2a5c31a3e6bf67bf8975df2a13e2e368691220 Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Thu, 15 Jun 2023 15:11:30 +0200 Subject: [PATCH] Do not mock git_helper.Git, suppress `git describe` error for ignore_no_tags --- tests/ci/docker_test.py | 9 ++------- tests/ci/git_helper.py | 7 ++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/ci/docker_test.py b/tests/ci/docker_test.py index 9d68f436439..d5d27f73694 100644 --- a/tests/ci/docker_test.py +++ b/tests/ci/docker_test.py @@ -10,9 +10,8 @@ from pr_info import PRInfo from report import TestResult import docker_images_check as di -with patch("git_helper.Git"): - from version_helper import get_version_from_string - import docker_server as ds +from version_helper import get_version_from_string +import docker_server as ds # di.logging.basicConfig(level=di.logging.INFO) @@ -312,7 +311,3 @@ class TestDockerServer(unittest.TestCase): for case in cases_equal: release = ds.auto_release_type(case[0], "auto") self.assertEqual(case[1], release) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/ci/git_helper.py b/tests/ci/git_helper.py index a9f2bf9b1cc..ab1caa42660 100644 --- a/tests/ci/git_helper.py +++ b/tests/ci/git_helper.py @@ -126,15 +126,16 @@ class Git: # Format should match TAG_REGEXP if self._ignore_no_tags and is_shallow(): try: - self._update_tags() + self._update_tags(True) except subprocess.CalledProcessError: pass return self._update_tags() - def _update_tags(self): - self.latest_tag = self.run("git describe --tags --abbrev=0") + def _update_tags(self, suppress_stderr: bool = False) -> None: + stderr = subprocess.DEVNULL if suppress_stderr else None + self.latest_tag = self.run("git describe --tags --abbrev=0", stderr=stderr) # Format should be: {latest_tag}-{commits_since_tag}-g{sha_short} self.description = self.run("git describe --tags --long") self.commits_since_tag = int(