Test your Mock knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.
Question 1/5Score 0
How does `unittest.mock.patch` handle patching a target that's used as a fixture/setup shared across multiple test methods in a test class?
Questions in this quiz
How does `unittest.mock.patch` handle patching a target that's used as a fixture/setup shared across multiple test methods in a test class?
What is the basic behavior of a `Mock` object when you access an attribute or call a method on it that you haven't explicitly configured?
What is a critical, commonly-misunderstood detail about WHERE to point `patch()` — patching where an object is defined versus where it's used?
What is the difference between `Mock` and `MagicMock`?
What is the purpose of `unittest.mock.patch` (often used as a decorator or context manager)?
What does `mock.assert_has_calls([call(1), call(2)])` verify, as opposed to `assert_called_with`?
What is `PropertyMock` used for?
What does `mock.reset_mock()` do?
What is a reasonable justification for writing a test that mocks a third-party HTTP API client, rather than making a real network call to that API during the test?
What does `mock.assert_called_once_with(arg1, arg2)` verify?
What is `Mock.side_effect` used for, beyond what `return_value` covers?
What is `create_autospec()` and how does it differ from `Mock(spec=SomeClass)`?