parent
f671fbc39b
commit
913a01c4b0
@ -0,0 +1 @@
|
|||||||
|
# This is the test package
|
@ -0,0 +1,26 @@
|
|||||||
|
import unittest
|
||||||
|
import a_wordcloud
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
# 获取当前文件所在目录的绝对路径
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# 获取 developed_code 目录的绝对路径,并添加到 sys.path 中
|
||||||
|
developed_code_path = os.path.abspath(os.path.join(current_dir, '..'))
|
||||||
|
sys.path.append(developed_code_path)
|
||||||
|
|
||||||
|
class TestAWordcloud(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_blue_color_func(self):
|
||||||
|
color = a_wordcloud.blue_color_func()
|
||||||
|
self.assertTrue(color.startswith("hsl(210, 100%,"))
|
||||||
|
|
||||||
|
def test_wordcloud_generation(self):
|
||||||
|
dm = {
|
||||||
|
'danmu': ["测试弹幕"] * 10
|
||||||
|
}
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
a_wordcloud.wordcloud_generation(dm)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -0,0 +1,25 @@
|
|||||||
|
import unittest
|
||||||
|
import bvid
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
# 获取当前文件所在目录的绝对路径
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# 获取 developed_code 目录的绝对路径,并添加到 sys.path 中
|
||||||
|
developed_code_path = os.path.abspath(os.path.join(current_dir, '..'))
|
||||||
|
sys.path.append(developed_code_path)
|
||||||
|
|
||||||
|
|
||||||
|
class TestBvid(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_get_source(self):
|
||||||
|
source = bvid.get_source(1)
|
||||||
|
self.assertTrue('bvid' in source)
|
||||||
|
|
||||||
|
def test_extract_bv(self):
|
||||||
|
html = '{"bvid":"test_bvid","title":"test"}'
|
||||||
|
bvs = bvid.extract_bv(html)
|
||||||
|
self.assertIn("test_bvid", bvs)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -0,0 +1,19 @@
|
|||||||
|
import unittest
|
||||||
|
import to_danmu
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
# 获取当前文件所在目录的绝对路径
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# 获取 developed_code 目录的绝对路径,并添加到 sys.path 中
|
||||||
|
developed_code_path = os.path.abspath(os.path.join(current_dir, '..'))
|
||||||
|
sys.path.append(developed_code_path)
|
||||||
|
|
||||||
|
class TestToDanmu(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_load_bv_numbers(self):
|
||||||
|
bv_numbers = to_danmu.load_bv_numbers("E:/Crawler/else/bv_numbers.txt")
|
||||||
|
self.assertIsInstance(bv_numbers, list)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -0,0 +1,20 @@
|
|||||||
|
import unittest
|
||||||
|
import to_excel
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
# 获取当前文件所在目录的绝对路径
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# 获取 developed_code 目录的绝对路径,并添加到 sys.path 中
|
||||||
|
developed_code_path = os.path.abspath(os.path.join(current_dir, '..'))
|
||||||
|
sys.path.append(developed_code_path)
|
||||||
|
|
||||||
|
class TestToExcel(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_filter_and_count_danmu(self):
|
||||||
|
danmu_list = ["AI 是未来", "机器学习", "AI 是未来", "人工智能"]
|
||||||
|
result = to_excel.filter_and_count_danmu(danmu_list)
|
||||||
|
self.assertEqual(result["AI 是未来"], 2)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in new issue