第二章
pytest运行方式
命令行终端运行测试用例,pytest -sv
python 程序运行测试用例,跟其他程序集成,pytest.main([‘-sv’])
# 终端控制台命令
#1、pytest
#2、pytest -sv 详细信息
#3、pytest -q .\Day01 # 指定package
#4、pytest -q .\Day01\test_01_pass_fail.py #指定模块
#5、pytest -q .\Day01\test_05_exceptions.py::test_student_score_raise #指定用例
数据类
dataclass这个模块提供了一个类装饰器和一些函数,用于自动添加生成的special method,例如 _init_()和_repr_()到用户定义的类。
对标准库的补充,称为数据类。可以将数据类视为“具有默认值的可变命名元组”。
数据类使用普通的类定义语法,你可以自由的使用继承、元类、文档字符串、用户定义的方法、类工厂和其他python类特性。
@dataclass 面向对象设计模式来设计我们的class类。
装饰器:https://www.ztloo.com/2021/11/06/decorators/
标准库:https://docs.python.org/zh-cn/3/library/index.html
参考: https://docs.python.org/3/library/dataclasses.html#m