AI engineering glossary · Python advanced
What is unittest.mock?
unittest.mock: A standard library module providing Mock objects and the patch tool for replacing parts of a program during tests and recording how they were called. It supports assertions such as assert_called_once_with.
unittest.mock: an example
with patch('app.send_sms') as m: run(); m.assert_called_once() checks that an SMS was attempted without sending one.
Related terms
More Python advanced terms
Where you learn it
unittest.mock is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.