既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
import pytest def test_add(): assert 1 + 1 =``= 2 def test_sub(): assert 2 - 1 =``= 1 |
通过 pytest test_example.py 运行此代码示例后,会触发pytest的入口函数main(),这个函数定义在src/pytest/__main__.py中,它的作用是创建一个PytestConfig对象,并调用其
do_configure()和do_main()方法。PytestConfig对象是pytest的核心配置类,它负责解析命令行参数、读取配置文件、注册插件、创建Session对象等。PytestConfig对象定义在
src/_pytest/config/__init__.py中,它继承了pluggy.HookimplMarker类,也就是说它可以作为一个插件管理器,调用各种hook函数。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ````python # src/pytest/main.py def main(): # 创建PytestConfig对象 config=` `PytestConfig()` `# 调用config.do_configure()方法` `config.do_configure()` `# 调用config.do_main()方法` `config.do_main()` `````````python` `# src/_pytest/config/__init__.py` `class` `PytestConfig(pluggy.HookimplMarker):` `def` `__init__( self):` |