pytest的许多实用插件。
项目描述
版权 (C) 2016 Samuel Colvin
pytest的许多实用插件。
固定装置
- tmpworkdir
以工作目录设置为临时目录的方式运行测试。类似于pytest插件 tmpdir,但工作目录已更改。
- smart_caplog
使用比pytest原生 caplog 更智能的接口捕获日志
- print_logs
打印所有日志。
- loop
asyncio循环。
方法
(下面是使用示例)。
- mktree
从字典创建文件树。
- gettree
返回表示目录树的字典。
比较对象
所有都可以从 pytest_toolbox.comparison 导入。
- CloseToNow
检查日期(或类似日期的对象)是否接近现在
- AnyInt
检查测试对象是否为int类型
- RegexStr
检查字符串是否匹配正则表达式
- IsUUID
检查对象是否是UUID的实例。
与equals一起使用,如 my_date == CloseToNow(),这些在检查包含一些未知值的对象时非常有用
例如。
assert {
'details': {
'user': 'foobar@example.com',
'id': AnyInt(),
'published': False,
'event': 'an example',
'created_ts': CloseToNow(),
},
'other_thing': [
...
],
...
} == obj
用法
from pytest_toolbox import gettree, mktree
def test_whatever(tmpworkdir):
mktree(tmpworkdir, {
'foobar.txt': 'has this content'
})
assert gettree(tmpworkdir) = {'foobar.txt': 'has this content'}
待办事项
项目详情
关闭
pytest-toolbox-0.4.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e23243aabd20dfb4e6ca7c1b18bcda3951119c7827898a535ef84d3e2915a673 |
|
MD5 | 524107c82087f613ac8af7134dc14792 |
|
BLAKE2b-256 | 7563ffc87832881f6d0c5899140a4e3d379f5f464f6185ac48c21a2f48662c11 |
关闭
pytest_toolbox-0.4-py35+-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 31db0ee5492e0878ece2a98687209cbd96952317c7e1b2a2423342db4a2db103 |
|
MD5 | 81f3142d390f27153bae3bdebf573b27 |
|
BLAKE2b-256 | c7011d183f6d5c9156da1a82e9d61f93eb8ecb3a7e388b0747e5db4d71e5109e |