mirror of
https://kkgithub.com/chinese-poetry/chinese-poetry.git
synced 2026-04-15 02:53:38 +00:00
test: add sqlite test
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
#! -*- coding: utf-8 -*-
|
#! -*- coding: utf-8 -*-
|
||||||
"""
|
import os, json, sqlite3
|
||||||
|
|
||||||
测试古诗JSON文件是否有效
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os, json
|
|
||||||
|
|
||||||
def check_json(f):
|
def check_json(f):
|
||||||
filepath = os.path.join('./json', f)
|
filepath = os.path.join('./json', f)
|
||||||
@@ -14,8 +8,27 @@ def check_json(f):
|
|||||||
_ = json.loads(file.read())
|
_ = json.loads(file.read())
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
assert False, "校验(%s)失败" % f
|
assert False, u"校验(%s)失败" % f
|
||||||
|
|
||||||
|
|
||||||
def test_json():
|
def test_json():
|
||||||
|
"""
|
||||||
|
测试古诗JSON文件是否有效
|
||||||
|
"""
|
||||||
map(check_json, os.listdir('./json'))
|
map(check_json, os.listdir('./json'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def test_sqlite():
|
||||||
|
"""
|
||||||
|
测试ci数据库文件是否有效
|
||||||
|
"""
|
||||||
|
conn = sqlite3.connect('./ci/ci.db')
|
||||||
|
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
c.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
||||||
|
|
||||||
|
tables = c.fetchall()
|
||||||
|
|
||||||
|
assert len(tables) == 2, u"Sqlite文件异常"
|
||||||
|
|||||||
Reference in New Issue
Block a user