pytest.ini文件读取
时间: 2024-07-04 14:00:35 浏览: 179
Pytest.ini是一个pytest测试框架的配置文件,它用于定制测试运行的行为、选择测试模块、设置报告格式等。当你使用pytest运行测试时,它会先查找当前目录下的pytest.ini文件,如果找不到则会向上级目录查找,直到找到或者到达根目录。
pytest.ini通常包含以下部分:
1. [pytest] 或者 [tool:pytest] 部分:包含了全局的pytest配置选项,例如测试标记(markers)、测试筛选规则(filter)等。
2. [pytest-runner] 部分:如果你的项目依赖于pytest-runner插件来管理测试,这里可以配置。
3. [tool:pytest] 或者 [pytest] 部分的子块:例如,你可以定义插件(plugins)、报告器(reporters)、标记(markers)等。
下面是一些常用的配置示例:
```ini
[pytest]
# 设置报告模式,如:auto, TerminalSummary, TerminalReplay, html等
python_files = test_*.py, tests/*.py
# 显示失败和错过的测试
failfast = True
# 自动发现测试模块
autodiscover = True
[pytest-reporter]
# 报告器的配置,比如:reports:选择要生成的报告类型
reports = terminal, junit
[markers]
slow = reason: mark a test as slow to skip it by default
```
阅读全文
相关推荐
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)