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.
Asked
Active
Viewed 1,017 times
2
Elliot Gorokhovsky
- 3,610
- 2
- 31
- 56
2 Answers
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