1

Reviewing PyHamcrest's API, I see there's an equal_to matcher

from hamcrest import *
assert_that('1', equal_to('1'))

but there's no parallel negative method such as not_equal_to

from hamcrest import *
assert_that('1', not_equal_to('2'))

What's the proper way of matching negative equality?

JJJ
  • 32,902
  • 20
  • 89
  • 102
noamt
  • 7,397
  • 2
  • 37
  • 59

1 Answers1

5

The proper way to match for negative equality is to chain the equal_to method with the is_not method

from hamcrest import *
assert_that('1', is_not(equal_to('1')))
noamt
  • 7,397
  • 2
  • 37
  • 59