"""
调用pytest
"""
# 在一个模块中运行测试
print("pytest test_*.py")
# 在一个目录中运行测试
print("pytest test/")
# 按关键字表达式运行测试 -k 执行文件名,类名,函数名包含 -k 参数的值 不区分大小写
print('pytest -k "test and not 2"') # 执行文件名,类名,函数名包含 test 的值但不包含2 的值
# 按节点id运行测试
print('python test_*.py::TestMy::test_1') # 执行test_*.py 模块下, TestMy 类 中的 test_1类函数
print('python test_*.py::test_1') # 执行test_*.py 模块下的test_1 函数
# 通过@pytest.mark.slow 按标签执行
print("pytest -m slow")
# 通过--pyargs 按包执行
print("pytest --pyargs api") # api为包名,包必须有__init_py 文件
print("pytest --pyargs api/test") # api为包名, test 为api包下的包包必须有__init_py 文件
# 通过python调用
print("python -m pytest ...") # pytest 后面接pytest参数命令
# 在python代码中调用
print("pytest.main()")