You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
import requests
|
|
from bs4 import BeautifulSoup
|
|
import re
|
|
import getcidfrombv as cid
|
|
import unittest
|
|
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0' }
|
|
|
|
|
|
class TestFunctions(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
# 在每个测试之前运行
|
|
self.content_list = [
|
|
'www.bilibili.com/video/BV1mE4m1R71o',
|
|
'www.bilibili.com/video/BV1wH4y1F7KD',
|
|
'www.bilibili.com/video/BV1M142187NQ',
|
|
'www.bilibili.com/video/BV1im42137XE',
|
|
'www.bilibili.com/video/BV1wS421d7Mj',
|
|
'www.bilibili.com/video/BV1FE4m1d7tS',
|
|
'www.bilibili.com/video/BV1PU411S7HC',
|
|
'www.bilibili.com/video/BV1fx4y1x7eW',
|
|
'www.bilibili.com/video/BV1rw4m1r7nF',
|
|
'www.bilibili.com/video/BV19E4m1R7Kf'
|
|
]
|
|
|
|
def test_getcid(self):
|
|
# 测试 sort 函数
|
|
expected_output = [
|
|
1646607366,
|
|
1663877514,
|
|
1648215637,
|
|
1627769596,
|
|
1628417603,
|
|
1640306641,
|
|
1627951394,
|
|
1650192254,
|
|
1649785565,
|
|
1629439509
|
|
]
|
|
actual_output=[]
|
|
bvs = []
|
|
for link in self.content_list:
|
|
bv = cid.extract__BV(link)
|
|
bvs.append(bv)
|
|
actual_output = cid.get_cid_from_bv(bvs)
|
|
self.assertEqual(expected_output, actual_output)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|
|
|