Skip to content

Commit 8bf8a1a

Browse files
committed
Refactor test setup and update Makefile for coverage reporting
1 parent f56cc3a commit 8bf8a1a

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fmt:
1010
@isort --profile black ./src ./tests ./gitlab_bot.py
1111

1212
test: lint
13-
@pytest --cov=an_copilot tests
13+
@pytest --cov=src tests
1414

1515
i18n:
1616
xgettext -d base -o src/locales/gitlab-bot.pot *.py

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ lint = [
3636
"isort>=5,<6",
3737
"black>=23,<24"
3838
]
39+
test = [
40+
"pytest==7.4.3",
41+
"coverage==7.2.7",
42+
"pytest-cov==4.1.0"
43+
]
3944
package = [
4045
"flit==3.9.0"
4146
]

tests/test_llm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23
import unittest
34
from unittest import TestCase
45

@@ -7,7 +8,10 @@
78

89
class TestLLM(TestCase):
910
def test_ai_diffs_summary(self):
10-
with open("git_diff.json", "r") as f:
11+
test_dir = os.path.dirname(os.path.abspath(__file__))
12+
file_path = os.path.join(test_dir, "git_diff.json")
13+
14+
with open(file_path, "r") as f:
1115
git_diff_json = json.loads(f.read())
1216
summary_report = ai_diffs_summary(git_diff_json)
1317
self.assertIn("AI 摘要(实验)", summary_report)

0 commit comments

Comments
 (0)