前言:
在对登录验证时,不知道为何原因用unittest的断言不成功,就在网上发现这个assertpy,因此做个笔记
准备:
pip install assertypy
例子:
from assertpy import assert_that def check_login():
url = driver.current_url
result = False
try: assert_that(url).is_equal_to("http://XXXXXXX")
print("pass")
return result
except:
print(u"登录失败")
result = True
return result
从github 主页文档,很强大,支持所有类型,支持了几乎你能想到的所有测试场景:
Strings
- Numbers
- Lists
- Tuples
- Dicts
- Sets
- Booleans
- None
- Dates
- Files
- Objects
源文档:
https://www.cnblogs.com/cicaday/p/python-assert.html#undefined