Exercise: Testing
Questions for: Testing
What is the purpose of the
unittest.mock.MagicMock.side_effect attribute in Python testing?
A:
Specifies the return value of a method
B:
Specifies the call count of a method
C:
Specifies the exception to be raised by a method
D:
Specifies the side effect of a method
Answer: C
The
side_effect attribute in Python's unittest.mock.MagicMock is used to specify the exception to be raised by a method.
What is the purpose of the
unittest.mock.MagicMock.assert_called_once method in Python testing?
A:
Asserts that a method was called exactly once
B:
Asserts that a method was not called
C:
Asserts that a method was called with specific arguments
D:
Asserts that a method was called with any arguments
Answer: A
The
assert_called_once method in Python's unittest.mock.MagicMock asserts that a method was called exactly once.Discuss About this Question.
What is the purpose of the
unittest.mock.MagicMock.reset_mock method?
A:
Resets the call count of a method
B:
Resets the return value of a method
C:
Resets the side effect of a method
D:
Resets all attributes of a mock object
Answer: D
The
reset_mock method in Python's unittest.mock.MagicMock resets all attributes of a mock object.Discuss About this Question.
What is the purpose of the
unittest.TestCase.addTypeEqualityFunc method in Python testing?
A:
Adds a new test case class
B:
Adds a custom equality function for specific types
C:
Adds a type assertion for test cases
D:
Adds a type-specific cleanup function
Answer: B
The
addTypeEqualityFunc method allows you to add a custom equality function for specific types in Python's unittest module.Discuss About this Question.
In Python's
unittest.mock module, what is the purpose of the MagicMock.assert_called_once_with method?
A:
Asserts that a method was called exactly once
B:
Asserts that a method was not called
C:
Asserts that a method was called with specific arguments
D:
Asserts that a method was called with any arguments
Answer: A
The
assert_called_once_with method in Python's unittest.mock.MagicMock asserts that a method was called exactly once with specific arguments.Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.