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.

Level: intermediateTopic: Python advanced

Mocking: an example

Patching requests.get to return a fixed JSON reply tests parsing code without touching the internet.

Related terms

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.