self.assertIsNotNone(self.driver.find_element_by_id('com.boohee.secret:id/tv_edit_profile'),'无编辑资料按钮,登录失败,Fail') 1. 2. 3. 4. 5. 6. 7. 8. 9. (1)这边是通过寻找id(com.boohee.secret:id/tv_edit_profile)的元素是否存在,如存在则pass;不存在则fail。 (2)后面的“无编辑资料...
| assertIsNone(self, obj, msg=None) | Same as self.assertTrue(obj is None), with a nicer default message. | | assertIsNot(self, expr1, expr2, msg=None) | Just like self.assertTrue(a is not b), but with a nicer default message. | | assertIsNotNone(self, obj, msg=None) |...
assertFalse:判断bool值为False,则Pass 使用方法: assertTrue(expr,msg)其中express输入相应表达式,如果表达式为真,则pass;msg选填;断言assertFalse如果表达式为假,则pass assertIsNone和assertIsNotNone assertIsNone:不存在,则pass assertIsNotNone:存在,则pass 使用方法: assertIsNone(obj,msg)检查某个元素是否存在 ...
AssertFunctionUserAssertFunctionUserget_greeting("Bob")"Hello, Bob!"assert result is not NoneOKget_greeting("")Noneassert result is not NoneAssertionError("返回结果为空!") 在这个序列图中,用户调用函数,函数返回结果,然后用户使用assert进行断言检查。当结果为空时,assert引发异常,反馈给用户。 结论 通过...
assertFalse(x,[msg]):断言x是否False,是False则测试用例通过。 assertIs(a,b,[msg]):断言a是否是b,是则测试用例通过。 assertNotIs(a,b,[msg]):断言a是否是b,不是则测试用例通过。 assertIsNone(x,[msg]):断言x是否None,是None则测试用例通过。 assertIsNotNone(x,[msg]):断言x是否None,不是None...
assertIsNone(expr, msg=None) 验证expr是None,不是则fail 8 assertIsNotNone(expr, msg=None) 验证expr不是None,是则fail 9 assertIn(arg1, arg2, msg=None) 验证arg1是arg2的子串,不是则fail 10 assertNotIn(arg1, arg2, msg=None) 验证arg1不是arg2的子串,是则fail 11 assertIsInstance(obj, cls...
self.assertGreater #判断a>b 成立则通过,否则失败 self.assertGreaterEqual #判断a>=b 成立则通过,否则失败 self.assertIsNone(obj=””) #判断obj=None 成立则通过,否则失败 self.assertIsNotNone #判断obj=None 成立则失败,否则通过 self.assertIsInstance(a,b) #判断a的数据类型是否为b,isinstance(a,b)...
self.assertIsNone(obj=””) #判断obj=None 成立则通过,否则失败 self.assertIsNotNone #判断obj=None 成立则失败,否则通过 self.assertIsInstance(a,b) #判断a的数据类型是否为b,isinstance(a,b) 成立则通过,否则失败 self.assertNotIsInstance #判断同上相反 self.assertRegexpMatches(a,b) #正则匹配 同...
Python的保留字或关键字是指我们不能把它们用作任何标识符名称,Python的33个保留字如下:False、None、True、and、as、assert、break、class、continue、def、del、elif、else、except、finally、for、from、global、if、import、in、is、lambda、nonlocal、not、or、pass、raise、return、try、while、with、yield。 当前...
断言方法有:ssertEqual、assertNotEqual、assertIn、assertNotIn、assertTrue、assertFalse、assertIsNone、assertIsNotNone。除此之外,还可以使用msg参数自定义异常。 unittest常用的断言方法 1.assertEqual(self, first, second, msg=None) --判断两个参数相等:first == second 2.assertNotEqual(self, first, ...