2

What is the best way to do assertEqual with unittest in Python, but instead of testing == it tests is? I want to ensure I have the same object, not just objects that compare equal. This is important, because some of the objects I'm working with are heap types with wacky compare operators.

Elliot Gorokhovsky
  • 3,610
  • 2
  • 31
  • 56

2 Answers2

5

That would be the assertIs method.

Ry-
  • 218,210
  • 55
  • 464
  • 476
4

Use assertIs which does exactly what you want.

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertIs

Amber
  • 507,862
  • 82
  • 626
  • 550