Python Mocking and Patching: How and Where to Patch — LearnFlat
⏱ 2 ساعة 30 دقيقة 📚 25 دورة 🎧 النسخة الصوتية

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.

  • 💬 مدرب ذكاء اصطناعي
    اسأل عن أي درس واحصل على إجابة واضحة فورًا، في أي وقت.
  • 🕐 ابدأ في أي وقت
    بلا جداول أو مواعيد نهائية — تعلّم بوتيرتك، وقتما يناسبك.
  • 🌐 بالعربية
    الدروس والمهام والشهادة — كل ذلك بلغتك بالكامل.

حول هذه الدورة

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.

ما الذي ستحصل عليه

  • 📜 شهادة إتمام
    أضفها إلى ملفك على LinkedIn
  • 💬 مدرّس AI شخصي
    عالق في دورة؟ اسأل مدرّسك المدمج أي شيء، في أي وقت.
  • 🎧 النسخة الصوتية مضمَّنة
    تعلَّم أثناء تنقُّلك — دون شاشة
  • ♾️ وصول مدى الحياة
    عُد متى شئت، بلا انتهاء
  • 📱 الهاتف أو الكمبيوتر
    يعمل في أي مكان وعلى أي جهاز
  • 💸 استرداد خلال 14 يومًا
    دون أسئلة
  • ⚡ قصير ومركَّز
    2 ساعة 30 دقيقة من المحتوى التطبيقي

المراجعات

لا توجد مراجعات بعد — كن أول من يشارك تجربته.

اكتب مراجعة

☆☆☆☆☆
سنطلب منك تسجيل الدخول بعد الإرسال — تُحفظ مسودتك.

المتعلمون أخذوا أيضًا

الأسئلة الشائعة

ما الذي أحتاجه لأخذ هذه الدورة؟ +

يكفي هاتف أو كمبيوتر متصل بالإنترنت. بدون تثبيتات أو أجهزة خاصة.

كيف يمكنني الدفع؟ +

بالبطاقة عبر Stripe. لا نخزن بيانات البطاقة — يتولى Stripe ذلك بأمان.

هل يمكنني استرداد المال؟ +

نعم — استرداد كامل خلال 14 يومًا، دون أسئلة.

إلى متى يستمر وصولي؟ +

إلى الأبد. بمجرد الشراء، الدورة لك تعود إليها متى شئت.

هل سأحصل على شهادة؟ +

نعم. عند الإتمام ستحصل على شهادة يمكنك إضافتها إلى ملفك في LinkedIn.

مصمَّم للعاملين في
التقنية التصميم المالية التسويق الرعاية الصحية التعليم الضيافة التصنيع