From 2e6fba3b3d80bbc3eadf159d97f8a30fe0a79483 Mon Sep 17 00:00:00 2001 From: Dong Zhou Date: Mon, 24 Jul 2023 00:50:38 -0400 Subject: [PATCH] fix unit tests --- gita/info.py | 7 ++++++- tests/test_main.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gita/info.py b/gita/info.py index e84af35..ba92141 100644 --- a/gita/info.py +++ b/gita/info.py @@ -170,7 +170,12 @@ def has_stashed(flags: List[str], path) -> bool: """ # FIXME: this doesn't work for repos like worktrees, bare, etc p = Path(path) / ".git" / "logs" / "refs" / "stash" - return p.is_file() + got = False + try: + got = p.is_file() + except Exception: + pass + return got def get_commit_msg(prop: Dict[str, str]) -> str: diff --git a/tests/test_main.py b/tests/test_main.py index a877160..5a15b3e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -143,7 +143,7 @@ def test_ls(self, monkeypatch, capfd): @patch("gita.info.get_head", return_value="master") @patch( "gita.info._get_repo_status", - return_value=("dirty", "staged", "untracked", "diverged"), + return_value=("dirty", "staged", "untracked", "", "diverged"), ) @patch("gita.info.get_commit_msg", return_value="msg") @patch("gita.info.get_commit_time", return_value="")