Test your Mock knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.
Question 1/12Score 0
What is `create_autospec()` and how does it differ from `Mock(spec=SomeClass)`?
In this round
What is `create_autospec()` and how does it differ from `Mock(spec=SomeClass)`?
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 `Mock.return_value` used for?
What does `mock.reset_mock()` do?
What is `Mock`'s `assert_not_called()` used to verify?
What problem does using `spec` or `autospec` (e.g. `Mock(spec=RealClass)` or `patch(..., autospec=True)`) solve?
What is `unittest.mock` (Python's "Mock" library)?
What does `mock.assert_called_once_with(arg1, arg2)` verify?
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 is a common downside/risk of over-mocking in a test suite (mocking too many collaborators of the code under test)?
What is `PropertyMock` used for?
What is the purpose of using a mock as a context manager via `patch(...)` combined with the `with` statement, versus the decorator form `@patch(...)`?