Skip to content

Commit 1f2503a

Browse files
committed
add 规范测试
1 parent 61e1594 commit 1f2503a

27 files changed

+120
-82
lines changed

360.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : 360.py
55
# @Version: 1.0.0
66
# @Time : 2019/8/21 15:47

Bing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : Bing.py
55
# @Version: 1.0.0
66
# @Time : 2019/8/21 15:47

Config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : Config.py
55
# @Version: 1.0.0
66
# @Time : 2019/8/27 10:28

Constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : Constants.py
55
# @Version: 1.0.0
66
# @Time : 2019/8/21 15:32

InquireDNS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : InquireDNS.py
55
# @Version: 1.0.0
66
# @Time : 2019/8/21 15:56

Mail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : Mail.py
55
# @Version: 1.0.0
66
# @Time : 2019/9/12 15:20
7-
# @Project: tool-gui-python
7+
# @Project: scripts_python
88
# @Package:
99
# @Software: PyCharm
1010
import json

Netsarang.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : Netsarang.py
55
# @Version: 1.0.0
66
# @Time : 2019/9/17 18:22
7-
# @Project: tool-gui-python
7+
# @Project: scripts_python
88
# @Package:
99
# @Software: PyCharm
1010

Pexels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : Pexels.py
55
# @Version: 1.0.0
66
# @Time : 2019/10/16 15:22
7-
# @Project: tool-gui-python
7+
# @Project: scripts_python
88
# @Package:
99
# @Software: PyCharm
1010
import asyncio

Test.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
#
4+
# @Author : bajins https://www.bajins.com
5+
# @File : Test.py
6+
# @Version: 1.0.0
7+
# @Time : 2020/9/30 13:00
8+
# @Project: scripts_python
9+
# @Package:
10+
# @Software: PyCharm
11+
# 单元测试框架,主要由四部分组成:测试固件、测试用例、测试套件、测试执行器
12+
import os
13+
import random
14+
import time
15+
import unittest
16+
17+
18+
class Test(unittest.TestCase):
19+
@classmethod
20+
def setUpClass(cls): # 启动执行一次
21+
print("execute setUpClass")
22+
23+
@classmethod
24+
def tearDownClass(cls): # 结束执行一次
25+
print("execute tearDownClass")
26+
27+
def setUp(self): # 每条用例执行前都要执行
28+
print("execute setUp")
29+
30+
def tearDown(self): # 每条用例执行后都要执行
31+
print("execute tearDown")
32+
33+
def test_one(self): # 注意所有测试方法都需要以test开头
34+
print('execute test_one')
35+
self.assertTrue('FOO'.isupper())
36+
37+
def testReptileUtil(self):
38+
# download_taobao_chromedriver()
39+
# download_chromedriver()
40+
from utils.ReptileUtil import SafeDriver
41+
safe_driver = SafeDriver("https://www.bajins.com") # 触发__del__
42+
# 仅仅从功能上来说,instance 变量与safe_driver变量完全一样
43+
# 所不同的是,使用with启用上下文管理器以后,在退出缩进的时候会执行__exit__中的内容。
44+
with SafeDriver("https://www.bajins.com") as instance: # 触发__exit__
45+
pass
46+
with safe_driver.driver as driver:
47+
pass
48+
49+
def testSystemUtil(self):
50+
# print(get_windows_software())
51+
from utils.SystemUtil import restart_process
52+
restart_process(os.path.abspath(__file__))
53+
54+
def testStringUtil(self):
55+
print(random.randint(1, 10))
56+
print(random.randint(2000, 2017))
57+
from utils.StringUtil import is_empty
58+
is_empty("")
59+
60+
def testFileUtil(self):
61+
from utils.FileUtil import count_dir_size
62+
print(count_dir_size("images"))
63+
from utils.FileUtil import size_unit_format
64+
print(size_unit_format(25635891))
65+
66+
def testMultipartFileUtil(self):
67+
# t = DownloadWorkerThread(r'http://a3.kuaihou.com/ruanjian/ucdnb.zip', 'd:\\ucdnb.zip', header)
68+
# t.start()
69+
url = input(u"The URL Waiting for downloading:")
70+
filename = input(u"The Filepath to save:")
71+
from utils.MultipartFileUtil import download
72+
t = download(url, filename)
73+
while t.is_alive():
74+
time.sleep(60)
75+
print("bye")
76+
77+
def testDatabaseUtil(self):
78+
from utils.DatabaseUtil import Sqlite3
79+
s3 = Sqlite3("test")
80+
s3.excel_to_db_com(r"./test.xlsx", "test", password="test")
81+
82+
83+
if __name__ == '__main__':
84+
unittest.main() # 测试所有

Wallhaven.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# @Author : bajins www.bajins.com
3+
# @Author : bajins https://www.bajins.com
44
# @File : Wallhaven.py
55
# @Version: 1.0.0
66
# @Time : 2019/10/12 10:27
7-
# @Project: tool-gui-python
7+
# @Project: scripts_python
88
# @Package:
99
# @Software: PyCharm
1010
import asyncio

0 commit comments

Comments
 (0)