![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 78
Lion...
攒点C币不容易
展开
-
Python metaclass
1 类亦为对象 class Person(): name = "Rocky" age = 18 def __init__(self, weight): self.weight = weight In[5]: person = Person(48) In[6]: print(person) <__main__.Person object at 0x00000277A5FC8DA0> In[7]: print(Person) &原创 2022-01-11 08:57:37 · 104 阅读 · 0 评论 -
Python3 requests
1 前言 官网中对requests的介绍是"HTTP for Humans" Requests allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor. There’s no need to manually add query strings to your URLs, or to form-encode your POST data. Keep-alive and HTTP c原创 2022-01-10 09:06:18 · 160 阅读 · 0 评论 -
Python3 unittest,入门
1 介绍 unittest借鉴了JUnit的思想,支持测试代码的初始化(setup)和回收(teardown),测试集,以及测试报告框架与测试用例的独立性 The unittest unit testing framework was originally inspired by JUnit and has a similar flavor as major unit testing frameworks in other languages. It supports test automation, s原创 2022-01-10 09:02:22 · 511 阅读 · 0 评论 -
pytest:接口测试用例封装
1 前言 默认情况下, pytest会查找test开头或结尾的module, Test开头的class, 以及test开头的方法 于是我们可能会给某个功能定义一个module或者class, 不同的场景再定义不同的function 然而接口测试的基本套路无非是构造请求参数, 发送请求, 校验响应结果 所以那么多的function都重复地进行着这些步骤, 试想, 如果将整个流程封装起来, 岂不美哉 2 简单实现 拿登录为例 每一个场景定义一个方法, 思路清晰, 只是写起来冗余 def test_login_w原创 2022-01-05 09:04:57 · 1664 阅读 · 0 评论 -
pytest:hooks
前言 pytest运行的整个过程中, 充满了各种Hook函数 覆写Hook函数虽然无法改变pytest的执行流程, 但可以实现用户自定义行为 比如collection阶段, 可以不局限于test开头的模块和方法; run阶段, 可以过滤特殊的方法 官网中描述了以下几种hook函数 Bootstrapping hooks, 启动pytest时引入 Initialization hooks, 初始化插件, 及conftest.py文件 Test running hooks, 执行case时调用 Collect原创 2022-01-05 09:03:32 · 513 阅读 · 0 评论 -
pytest:基本介绍
1 前言 pytest,作为一款测试框架,并没有继续模仿junit层次分明的工作模式,以至于读完官网文档都感觉是懵的 虽然没有明确定义setup/teardown方法,却有其独特的手段实现相同的功能 流程控制建立在function的基础上,粒度或许更细,但并不容易上手 fixture功能过于强大,强大到你都不知道如何使用它 各种插件,还支持自定义 2 Fixtures 不同的unittest中的fixture,pytest中的fixture功能更强大,不仅能实现setup/teardown,还能实现参数原创 2022-01-05 09:02:53 · 421 阅读 · 0 评论