Exam 200-901 All QuestionsBrowse all questions from this exam
Question 471

Refer to the exhibit. Which code should be added at the snippet to perform a unit test?

    Correct Answer: D

    In the context of unit testing in Python using the unittest module, the correct method to check if the returned value of a function matches the expected value is self.assertEqual(a, b, msg). Here, send_message('hello') should return 'hello', and self.assertEqual checks for this equality. Option D matches this requirement correctly.

Discussion
christyronny7Option: D

D is correct

kymoni

Could someone explain the options? Why is there "Should be the same"?

christyronny7

"Should be the same" is the string that will be printed in the output if the test fails. The answer is D.