为什么 PyHamcrest 没有负相等匹配器?
Why doesn't PyHamcrest have a negative equality matcher?
查看 PyHamcrest's API,我发现有一个 equal_to
匹配器
from hamcrest import *
assert_that('1', equal_to('1'))
但没有not_equal_to
等并行否定法
from hamcrest import *
assert_that('1', not_equal_to('2'))
匹配负相等的正确方法是什么?
匹配负相等的正确方法是将 equal_to
方法与 is_not
方法链接起来
from hamcrest import *
assert_that('1', is_not(equal_to('1')))
查看 PyHamcrest's API,我发现有一个 equal_to
匹配器
from hamcrest import *
assert_that('1', equal_to('1'))
但没有not_equal_to
from hamcrest import *
assert_that('1', not_equal_to('2'))
匹配负相等的正确方法是什么?
匹配负相等的正确方法是将 equal_to
方法与 is_not
方法链接起来
from hamcrest import *
assert_that('1', is_not(equal_to('1')))