测试数据目录和文件的pytest插件
pytest-datadir的Python项目详细描述
Pytest数据目录
用于操作测试数据目录和文件的pytest插件。
用法
pytest datadir将查找具有模块名或全局“data”文件夹的目录。 假设您有这样的结构:
.
├── data/
│ └── hello.txt
├── test_hello/
│ └── spam.txt
└── test_hello.py
您可以使用注入的变量datadir
(对于test{eem>文件夹)或shared_datadir
访问这些文件的内容。
(对于data文件夹):
deftest_read_global(shared_datadir):contents=(shared_datadir/'hello.txt').read_text()assertcontents=='Hello World!\n'deftest_read_module(datadir):contents=(datadir/'spam.txt').read_text()assertcontents=='eggs\n'
pytest datadir会将原始文件复制到临时文件夹中,因此更改文件内容不会更改原始数据文件。
datadir
和shared_datadir
设备都是pathlib.Path
对象。
发布
按照以下步骤制作新版本:
- 从
master
创建新分支release-X.Y.Z
。 - 更新
CHANGELOG.rst
。 - 打开公关。
- 在green和approved之后,按^{
>格式推送一个新标记。
travis将自动部署到pypi。
然后,在conda-forge/pytest-datadir-feedstock中更新配方。
许可证
麻省理工学院。