Skip to content

Commit 9ed383a

Browse files
Wael MahlousMatthew Scroggs
andcommitted
Add git info test
As per issue #8, the git-related code is not being tested. This commit can be a starting point for git-related tests. It exposes the repo object, which in turn can be used for various assertions. Completed during UCL ARC's Winter Open-Source Good First Issue Hackathon. Co-authored-by: Matthew Scroggs <mscroggs@users.no-reply.github.com>
1 parent b707f21 commit 9ed383a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

fancylog/tools/git.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def __init__(self, repo):
5050
repo
5151
A gitpython repo object.
5252
"""
53+
self.repo = repo
5354
self.head = GitHead(repo.head.commit)
5455

5556

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ python =
118118
[testenv]
119119
extras =
120120
dev
121+
git
121122
commands =
122123
pytest -v --color=yes --cov=fancylog --cov-report=xml
123124
"""

tests/tests/test_general.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from rich.logging import RichHandler
1212

1313
import fancylog
14+
import fancylog.tools.git
1415

1516
lateral_separator = "**************"
1617

@@ -425,3 +426,10 @@ def test_mock_no_environment(tmp_path):
425426

426427
assert f"{'fancylog':20} {'1.1.1'}"
427428
assert f"{'pytest':20} {'1.1.1'}"
429+
430+
431+
def test_git_info():
432+
repo = fancylog.tools.git.get_git_info("").repo
433+
for _c in repo.iter_commits():
434+
pass
435+
assert _c.message == "Initial commit"

0 commit comments

Comments
 (0)