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