ZHIWEI666 commited on
Commit
5410801
·
verified ·
1 Parent(s): b267d43

Upload 测试脚本.py

Browse files
Files changed (1) hide show
  1. 测试脚本.py +5 -3
测试脚本.py CHANGED
@@ -132,9 +132,11 @@ class TestDatabaseConnection(unittest.TestCase):
132
  def tearDown(self):
133
  """测试后清理"""
134
  import os
135
- test_path = Path(__file__).parent / "data" / self.test_file
136
- if test_path.exists():
137
- os.remove(test_path)
 
 
138
 
139
  def test_load_missing_file(self):
140
  """测试:加载不存在的文件返回空列表"""
 
132
  def tearDown(self):
133
  """测试后清理"""
134
  import os
135
+ # 🔧 修复:旧版清理路径写死为 data/,与实际存储目录(数据库连接.LOCAL_DB_DIR,本地为 cache/)不匹配导致残留
136
+ from 数据库连接 import LOCAL_DB_DIR, BACKUP_DIR
137
+ for test_path in (Path(LOCAL_DB_DIR) / self.test_file, Path(BACKUP_DIR) / f"{self.test_file}.bak"):
138
+ if test_path.exists():
139
+ os.remove(test_path)
140
 
141
  def test_load_missing_file(self):
142
  """测试:加载不存在的文件返回空列表"""