08 2017 档案
摘要:使用HTMLTestRunner运行测试套件,自动生成html测试报告: 1 import unittest, HTMLTestRunner, sendmail_html 2 import time, os 3 4 case_dir = 'D:\\pywork\\pyworkspace\\yzwx_selenium\\batch_case\\test_cases' 5 t = tim...
阅读全文
摘要:1 # 通过对NC文件复制来造数据 2 import os, shutil 3 4 # 遍历的根目录 5 root_dir = "D:\\test_data\\DISASTER\\" 6 # 获取NC文件的时间 7 time_source = '20161228080000' 8 # 生成NC文件的时间 9 time_new = '201812280...
阅读全文
摘要:1 # 多线程举例 2 from threading import Thread 3 from threading import current_thread 4 5 6 class messager(Thread): 7 def run(self): 8 for x in range(20): 9 print(curre...
阅读全文
摘要:1 # 发送html内容的邮件 2 import smtplib, time, os 3 from email.mime.text import MIMEText 4 from email.header import Header 5 6 7 def send_mail_html(file): 8 '''发送html内容邮件''' 9 # 发送邮箱 10...
阅读全文
摘要:1 import logging 2 3 4 # 简单打印日志举例 5 logging.basicConfig(level=logging.DEBUG) # 设置日志级别,WARN 6 logging.warning('Watch out!') # will print a message to the console 7 logging.info('I told yo...
阅读全文
摘要:使用os模块查询指定目录下的最新文件 1 import os 2 3 # 输入目录路径,输出最新文件完整路径 4 def find_new_file(dir): 5 '''查找目录下最新的文件''' 6 file_lists = os.listdir(dir) 7 file_lists.sort(k
阅读全文
摘要:Counter类:计算序列中出现次数最多的元素 运行结果:
阅读全文
摘要:文件系统操作(os模块) 运行结果: 文件遍历: 遍历目录下所有文件包括子目录 os.walk功能:递归遍历目录下的文件和子目录,参数(需要遍历的目录,排序=ture为顺序) 返回三个值:当前目录、当前目录下的目录列表和当前目录下的文件列表 运行结果:
阅读全文
摘要:自动保存图表:pyplot.savefig('D:\\pic.png'),替代了 pyplot.show()。 1 # 使用matplotlib.pyplot.scatter绘制散点 2 import matplotlib.pyplot as plt 3 from pylab import mpl 4 5 # 设置默认字体,解决中文显示乱码问题 6 mpl.rcParams['fo...
阅读全文
摘要:把写好的测试用例放在指定目录下,使用discover函数扫描该目录,并根据关键字自动筛选需要执行的用例。本例使用Python3.6版本。
阅读全文
摘要:到这里完成了一条完整的测试用例,但如果有多条测试用例需要一起执行,后续说明。
阅读全文
摘要:1 # 使用smtplib模块发送邮件 2 import smtplib 3 from email.mime.text import MIMEText 4 from email.header import Header 5 6 # 发送邮箱 7 sender = 'xxx@163.com' 8 # 接收邮箱 9 receiver = 'xxx@qq.com' 10 # 发送邮...
阅读全文
摘要:itemgetter函数:对字典列表进行多键排序 运行结果:
阅读全文