Exercise: Testing
Questions for: Testing
What does the
unittest.TestCase.addCleanup method allow you to do?
A:
Adds a cleanup function to be run after the test method
B:
Adds a setup function to be run before the test method
C:
Adds a sub-test to the test case
D:
Adds a condition to skip the test
Answer: A
The
unittest.TestCase.addCleanup method is used to add a cleanup function to be run after the test method in Python unittest.
What is the purpose of the
unittest.mock.Mock.assert_has_calls method in Python testing?
A:
Asserts that a method was called at least once
B:
Asserts that a method was called exactly once
C:
Asserts that a method was not called
D:
Asserts that a method was called with specific arguments in a specific order
Answer: D
The
assert_has_calls method in Python unittest.mock.Mock asserts that a method was called with specific arguments in a specific order.Discuss About this Question.
In Python testing, what does the
unittest.skipUnless decorator do?
A:
Skips the entire test case
B:
Skips the next test method
C:
Skips the test unless a condition is True
D:
Marks the test as skipped
Answer: C
The
unittest.skipUnless decorator is used to skip a test unless a specified condition is True in Python's unittest module.Discuss About this Question.
In Python's
unittest module, what does the unittest.skipIf decorator do?
A:
Skips the entire test case
B:
Skips the next test method
C:
Skips the test unless a condition is True
D:
Marks the test as skipped
Answer: C
The
unittest.skipIf decorator is used to skip a test unless a specified condition is True in Python's unittest module.Discuss About this Question.
What is the purpose of the
unittest.mock.MagicMock.side_effect attribute?
A:
Adds a magical side effect to the test
B:
Specifies the return value of a method
C:
Specifies the call count of a method
D:
Specifies the exception to be raised by a method
Answer: D
The
side_effect attribute in Python unittest.mock.MagicMock is used to specify the exception to be raised by a method.Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.