What assertion method will you use when you test object equality (operator ==)?

Questions & AnswersCategory: PythonWhat assertion method will you use when you test object equality (operator ==)?
Lokesh Kumar Staff asked 2 years ago

What assertion method will you use when you test object equality (operator ==)?
a. unittest.TestCase.assertEqual()
b. unittest.TestCase.assertRaises()
c. unittest.TestCase.assertTrue()
d. unittest.TestCase.assertFalse()
e. unittest.TestCase.assertIn()

1 Answers
Lokesh Kumar Staff answered 2 years ago

a. unittest.TestCase.assertEqual()
 
Explanation:

assertEqual(first, second, msg=None) – test that first and second are equal. If the values do not compare equal, the test will fail.