AI engineering glossary · Python advanced
What is mocking?
Mocking (also called Mock): Replacing a real object, such as an API client or database, with a controllable fake during tests. It isolates the code under test, avoids slow or costly calls and lets you simulate errors.
Mocking: an example
Patching requests.get to return a fixed JSON reply tests parsing code without touching the internet.
Related terms
- unittest.mock
- Unit test
- Test double
- pytest
More Python advanced terms
Where you learn it
Mocking is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.