zoukankan      html  css  js  c++  java
  • unittest 常用的断言方法


    1.assertEqual(self, first, second, msg=None)
    --判断两个参数相等:first == second


    2.assertNotEqual(self, first, second, msg=None)
    --判断两个参数不相等:first != second


    3.assertIn(self, member, container, msg=None)
    --判断是字符串是否包含:member in container


    4.assertNotIn(self, member, container, msg=None)
    --判断是字符串是否不包含:member not in container


    5.assertTrue(self, expr, msg=None)
    --判断是否为真:expr is True


    6.assertFalse(self, expr, msg=None)
    --判断是否为假:expr is False


    7.assertIsNone(self, obj, msg=None)
    --判断是否为 None:obj is None


    8.assertIsNotNone(self, obj, msg=None)

    --判断是否不为 None:obj is not None

    ( msg=None,这个 msg 参数就是遇到异常后自定义输出信息 )

  • 相关阅读:
    初识jQuery(2)
    初识jQuery(1)
    document和javaScript内置对象
    location
    history
    window对象
    注释、语法约定、函数和作用域
    运算符和typeof
    string
    数据恢复
  • 原文地址:https://www.cnblogs.com/wangfan9/p/13652099.html
Copyright © 2011-2022 走看看