提交 8e572721 编写于 作者: C crj1998

add test

上级 6fb6a1ff
......@@ -2,8 +2,7 @@
The Command Line Interface (CLI) for the downloader
"""
import os, argparse, logging, json
import sys
sys.path.append('D:\workspace\meetslut')
from meetslut.webparser import ParserFactory
from meetslut.download import download
......
......@@ -7,11 +7,11 @@ GET_CFG = {
'headers': {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
},
# 'proxies': None,
'proxies': {
'http': 'socks5h://127.0.0.1:2801',
'https': 'socks5h://127.0.0.1:2801'
},
'proxies': None,
# 'proxies': {
# 'http': 'socks5h://127.0.0.1:2801',
# 'https': 'socks5h://127.0.0.1:2801'
# },
'timeout': 5
}
"""
......
import sys
sys.path.append('D:\workspace\meetslut')
# import sys
# sys.path.append('D:\workspace\meetslut')
from typing import Union, Optional
from abc import ABCMeta, abstractmethod
......
[build-system]
requires = ["setuptools>=42", "beautifulsoup4"]
requires = ["setuptools>=42", "beautifulsoup4", "lxml"]
build-backend = "setuptools.build_meta"
\ No newline at end of file
# import sys
# sys.path.append('D:\workspace\meetslut')
from datetime import datetime
import unittest
from meetslut.config import GET_CFG
from meetslut.download import amend_suffix
from meetslut.webparser import ParserFactory
from meetslut.download import download
class Tester(unittest.TestCase):
# def setUp(self):
# print(f'Test start @: {datetime.now().strftime("%Y-%m-%d, %H:%M:%S")}')
# def tearDown(self):
# print(f'Test end @: {datetime.now().strftime("%Y-%m-%d, %H:%M:%S")}')
def test_amend_suffix(self):
self.assertEqual(amend_suffix('.gif'), '.gif', 'error')
self.assertEqual(amend_suffix('.jiff'), '.jpg', 'error')
def test_factory(self):
for url in [
'https://caitlin.top/home',
'https://www.99zipai.com/selfies',
'https://motherless.com/'
]:
p = ParserFactory.create(url)
self.assertTrue(p)
@unittest.skipIf(GET_CFG['proxies'] is None, "Skiped: the proxy is necessary.")
def test_bool_value(self):
self.assertTrue(self.test_class.is_string("hello world!"))
if __name__ == '__main__':
# build test
suite = unittest.TestSuite()
suite.addTest(Tester('test_amend_suffix'))
suite.addTest(Tester('test_factory'))
# execute test
runner = unittest.TextTestRunner()
runner.run(suite)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册