随笔分类 -  自动化测试

摘要:unittest Python内置的单元测试框架,跟pytest类似 setup/teardown 在用例执行之前执行setup 接着执行用例本身 最后,执行teardown setupclass/teardownclass 在类中,所有用例执行之前执行setupclass 执行用例本身 当所有的用 阅读全文
posted @ 2020-01-29 18:16 干it的小张 阅读(150) 评论(0) 推荐(0)
摘要:import unittestimport osif __name__ == '__main__': base_dir = os.path.dirname(os.path.abspath(__file__)) # 写法一: suite = unittest.TestLoader().discover 阅读全文
posted @ 2020-01-29 18:13 干it的小张 阅读(285) 评论(0) 推荐(0)
摘要:import unittestclass TestCase2(unittest.TestCase): def test_case_01(self): self.assertTrue(1) def test_case_02(self): self.assertTrue(0) def test_case 阅读全文
posted @ 2020-01-29 18:11 干it的小张 阅读(156) 评论(0) 推荐(0)
摘要:import unittestimport requests# 版一:class MyTestCase(unittest.TestCase): def setUp(self): print("初始化") def tearDown(self): print("收尾") def xxxTest(self 阅读全文
posted @ 2020-01-29 18:10 干it的小张 阅读(160) 评论(0) 推荐(0)
摘要:About unittest是Python内置的单元测试框架(模块),不仅可以完成单元测试,也适用于web自动化测试中。 unittest提供了丰富的断言方法,判断测试用例是否通过,然后生成测试结果报告。 必要的准备与注意事项 首先,我们准备这样一个目录: M:\tests\ # 我的是M盘的tes 阅读全文
posted @ 2020-01-28 12:41 干it的小张 阅读(317) 评论(0) 推荐(0)
摘要:sys: 从Python3.2版本开始,sys模块移除了sys.setdefaultencoding方法,因为该setfaultencoding方法是在解决Python2.x中的字符编码的问题,而Python3.x中使用utf8后,就不再需要使用该方法 hashlib: import hashlib 阅读全文
posted @ 2020-01-27 19:04 干it的小张 阅读(258) 评论(0) 推荐(0)
摘要:1.把软件开发规范的相关目录建立起来 2、配置settings: import osimport datetimeimport shutilimport sysbase_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 阅读全文
posted @ 2020-01-26 21:23 干it的小张 阅读(778) 评论(0) 推荐(0)
摘要:什么是日志 日志是对软件执行时所发生事件的一种追踪方式。软件开发人员对他们的代码添加日志调用,借此来指示某事件的发生。一个事件通过一些包含变量数据的描述信息来描述(比如:每个事件发生时的数据都是不同的)。开发者还会区分事件的重要性,重要性也被称为等级或严重性。 什么时候使用日志 日志(logging 阅读全文
posted @ 2020-01-26 20:14 干it的小张 阅读(230) 评论(0) 推荐(0)
摘要:import os# 导入压缩文件用的模块import zipfileBASE = os.path.dirname(os.path.abspath(__file__))print(BASE)# 要压缩文件夹的根路径并拼接:base_dir = os.path.join(BASE,"allure_ht 阅读全文
posted @ 2020-01-25 17:42 干it的小张 阅读(288) 评论(0) 推荐(0)
摘要:版一: import timeimport datetimefrom selenium import webdriverfrom selenium.webdriver.support.wait import WebDriverWait # 等待页面加载某些元素from selenium.webdri 阅读全文
posted @ 2020-01-24 23:50 干it的小张 阅读(234) 评论(0) 推荐(0)
摘要:如果要发送其他类型的,如果PDF、doc、xls、MP3格式的,我们都可以通过MIMEApplication来完成,MIMEApplication默认子类型是application/octet-stream,而application/octet-stream表明这是个二进制文件,但愿接收方知道怎么处 阅读全文
posted @ 2020-01-24 00:32 干it的小张 阅读(270) 评论(0) 推荐(0)
摘要:import smtplibfrom email.mime.text import MIMETextfrom email.header import Headerfrom email.mime.image import MIMEImagefrom email.mime.multipart impor 阅读全文
posted @ 2020-01-23 23:59 干it的小张 阅读(647) 评论(0) 推荐(0)
摘要:import smtplibfrom email.mime.text import MIMETextfrom email.header import Header# 第三方 SMTP 服务# 设置服务器mail_host = "smtp.qq.com"# 用户名mail_user = "132068 阅读全文
posted @ 2020-01-23 23:44 干it的小张 阅读(251) 评论(0) 推荐(0)
摘要:import smtplibfrom email.mime.text import MIMETextfrom email.header import Header# 第三方 SMTP 服务# 设置服务器mail_host = "smtp.qq.com"# 用户名mail_user = "132068 阅读全文
posted @ 2020-01-23 23:34 干it的小张 阅读(181) 评论(0) 推荐(0)
摘要:前言 我们在Django中会碰到发送邮件的需求,Django中内置了邮件发送功能,被定义在django.core.mail模块中。发送邮件需要使用SMTP服务器,常用的免费服务器有:163、126、QQ,下面以163邮件为例。 思路 使用Django发送邮件就相当于,事先准备好一个可用的邮箱账户,并 阅读全文
posted @ 2020-01-23 12:01 干it的小张 阅读(224) 评论(0) 推荐(0)
摘要:直接上代码: import time import datetime from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait # 等待页面加载某些元素 from selenium 阅读全文
posted @ 2020-01-23 11:56 干it的小张 阅读(365) 评论(0) 推荐(0)
摘要:通过SMTP发邮件 首先要了解几个协议: SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式。它定义了邮件客户端和SMTP邮件服务器之间,以及两台SMTP邮件服务器之间的通信规则。 POP3 阅读全文
posted @ 2020-01-22 00:15 干it的小张 阅读(154) 评论(0) 推荐(0)
摘要:import xlrd#打开文件并拿到book对象:book = xlrd.open_workbook(r"D:\s27\day68\接口测试示例.xlsx")sheet = book.sheet_by_index(0)print(sheet)#获取行:# print(sheet.nrows)#获取 阅读全文
posted @ 2020-01-21 23:50 干it的小张 阅读(182) 评论(0) 推荐(0)
摘要:import pytestimport requestsimport allure l = [ { "url": "https://www.v2ex.com/api/site/info.json", "title":"v2ex的title", "desc":"v2ex的描述信息", "expect" 阅读全文
posted @ 2020-01-21 21:34 干it的小张 阅读(597) 评论(0) 推荐(0)
摘要:下载:pip install allure-pytest下载jdk 配置Java环境 配置pytest.ini [pytest]addopts = -s -v --html=report/report.html --alluredir ./report/resulttestpaths = ./scr 阅读全文
posted @ 2020-01-21 14:24 干it的小张 阅读(325) 评论(0) 推荐(0)