All quizzes
Free quiz · 20 questions in the bank

Mock quiz

Test your Mock knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/5Score 0

What is `Mock.side_effect` used for, beyond what `return_value` covers?

Questions in this quiz
  1. What is `Mock.side_effect` used for, beyond what `return_value` covers?
  2. What is `PropertyMock` used for?
  3. What is the purpose of `unittest.mock.patch` (often used as a decorator or context manager)?
  4. What does `patch.object(SomeClass, 'method_name')` do, as opposed to `patch('module.SomeClass.method_name')`?
  5. What is `Mock.return_value` used for?
  6. What is `unittest.mock` (Python's "Mock" library)?
  7. What is a common downside/risk of over-mocking in a test suite (mocking too many collaborators of the code under test)?
  8. What does `mock.assert_called_once_with(arg1, arg2)` verify?
  9. What does `mock.assert_has_calls([call(1), call(2)])` verify, as opposed to `assert_called_with`?
  10. What is the difference between `Mock` and `MagicMock`?
  11. What does `mock.reset_mock()` do?
  12. What problem does using `spec` or `autospec` (e.g. `Mock(spec=RealClass)` or `patch(..., autospec=True)`) solve?
Gaps to close?
Read the curated Mock notes — core concepts, patterns, interview prep.
Mock notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web