From 3f96c9c6502243b06efd4bb34a189e72e3a5557c Mon Sep 17 00:00:00 2001
From: yearning <10538594+wangweifeng1999@user.noreply.gitee.com>
Date: 星期一, 28 九月 2026 19:24:55 +0800
Subject: [PATCH] 复制项目

---
 backend/tests/test_grading.py |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/backend/tests/test_grading.py b/backend/tests/test_grading.py
new file mode 100644
index 0000000..8997aac
--- /dev/null
+++ b/backend/tests/test_grading.py
@@ -0,0 +1,18 @@
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+
+from app.grading import grade_item, normalize_answer
+
+
+def test_multi_choice_normalize():
+    assert normalize_answer("A,B,C,D", 288) == "ABCD"
+    assert normalize_answer("ABCD", 288) == "ABCD"
+
+
+def test_single_grade():
+    ok, sc = grade_item("A", "A", None, 272, 1.0)
+    assert ok and sc == 1.0
+    ok, sc = grade_item("B", "A", None, 272, 1.0)
+    assert not ok and sc == 0.0

--
Gitblit v1.8.0