The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily.
assertIs测试与is和is not运算符相同的对象标识:
The operators is and is not test for object identity: x is y is true if and only if x and y are the same object. x is not y yields the inverse truth value.
使用
assertEqual
两个对象不必是同一类型,它们只需要是相同的值。相比之下,使用assertIs
时,两个对象需要是相同的对象。assertEqual
类似于==
运算符的相等性测试:assertIs
测试与is
和is not
运算符相同的对象标识:以上两个引号都来自Python文档部分5.9 Comparisons。
相关问题 更多 >
编程相关推荐