Python Mocking and Patching: How and Where to Patch
Master the unittest.mock library to isolate your code, mock external dependencies, and write reliable unit tests by learning exactly where to apply patches.
-
💬
Instrutor de IA
Pergunte sobre qualquer aula e receba uma resposta clara na hora, quando quiser. -
🕐
Comece quando quiser
Sem horários nem prazos: aprenda no seu ritmo, quando quiser. -
🌐
Em português
Aulas, tarefas e certificado: tudo totalmente no seu idioma.
Sobre este curso
Writing unit tests for Python applications often requires isolating your code from external APIs, databases, or complex modules. But understanding how to mock dependencies—and specifically where to apply patches—is one of the most common hurdles for developers. This text-based course demystifies the patching process, giving you a clear mental model of how Python imports work and how to intercept them during testing.
By the end of this course, you will transition from guessing how to mock your code to confidently configuring test doubles. You will understand how to write clean, maintainable tests that execute quickly without relying on external systems.
What you'll learn:
- Understand the foundational concepts of test doubles, mocks, and patches in Python testing.
- Learn the crucial rules of where to patch objects based on import styles.
- Configure mock return values and side effects to simulate success states and error handling.
- Apply the patch decorator and context managers appropriately within your test structure.
- Practice isolating database calls and external API requests in realistic scenarios.
- Use modern pytest conventions alongside unittest.mock for clean test suites.
You will begin by mastering essential testing terminology and foundational mock behavior. From there, you will explore step-by-step written examples that illustrate how imports affect patching, and learn how to refactor fragile tests into robust, isolated suites.
This course is designed for Python developers who understand basic language syntax and want to elevate their testing skills. No prior experience with mocking is required.
Start reading today to write cleaner, faster, and more reliable Python tests.
O que você vai receber
-
📜
Certificado de conclusão
Adicione ao seu perfil do LinkedIn -
💬
Tutor AI pessoal
Travou em uma aula? Pergunte ao seu tutor integrado qualquer coisa, a qualquer hora. -
🎧
Versão em áudio incluída
Estude em qualquer lugar, sem tela -
♾️
Acesso vitalício
Volte quando quiser, sem expirar -
📱
Celular ou computador
Funciona em qualquer dispositivo -
💸
Reembolso em 14 dias
Sem perguntas -
⚡
Curto e focado
2 h 30 min de conteúdo prático
Avaliações
Ainda não há avaliações — seja o primeiro a compartilhar sua experiência.
Outros também fizeram
⚡ Ideal para começar
🎓 Com certificado
Hands-On Python Programming: Aprenda construindo projetos práticos
Certificado
Prática
5 400 ֏
→
🔥 Em demanda
🎓 Com certificado
Python Profissional: Construa Aplicações Estruturadas
Certificado
Prática
5 400 ֏
→
🔥 Em demanda
🎓 Com certificado
Padrões de Design em Python: Fundamentos da Arquitetura Orientada a Objetos
Certificado
Prática
5 400 ֏
→
🔥 Em demanda
🎓 Com certificado
Programação Python e Desenvolvimento de Aplicações
Certificado
Prática
5 400 ֏
→
Perguntas frequentes
O que preciso para fazer este curso? +
Só um celular ou computador com internet. Sem instalações nem hardware especial.
Como faço para pagar? +
Com cartão via Stripe. Não guardamos dados do cartão — o Stripe processa com segurança.
Posso pedir reembolso? +
Sim — reembolso integral em 14 dias, sem perguntas.
Por quanto tempo terei acesso? +
Para sempre. Uma vez comprado, o curso é seu para revisar quando quiser.
Vou receber um certificado? +
Sim. Ao concluir, você recebe um certificado que pode adicionar ao seu perfil do LinkedIn.
Feito para profissionais em
Tecnologia
Design
Finanças
Marketing
Saúde
Educação
Hotelaria
Indústria