Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What does unittest.mock allow you to do?
Think about testing multiple components.
What is the purpose of patching?
Consider why you would want to avoid real objects.
What is the main purpose of mocking?
Think about the role of mocks in tests.
True or False: Patching replaces the original object for the duration of the test.
Consider how patches work in practice.
You have a function that fetches user data from an external API. Write a test for this function using mocking and explain why your approach is correct.
Consider what should happen if the API is down.
Determine the implications of using mocking for unit tests when real interactions are necessary. Create a mock scenario and describe the outcomes.
Think about potential edge cases that might be missed.
6 more questions in this section. Enroll free to practise them all.
Enroll free