René's URL Explorer Experiment


Title: Understanding the Python Mock Object Library – Real Python

Open Graph Title: Understanding the Python Mock Object Library – Real Python

Description: In this tutorial, you'll learn how to use the Python mock object library, unittest.mock, to create and use mock objects to improve your tests. Obstacles like complex logic and unpredictable dependencies make writing valuable tests difficult, but unittest.mock can help you overcome these obstacles.

Open Graph Description: In this tutorial, you'll learn how to use the Python mock object library, unittest.mock, to create and use mock objects to improve your tests. Obstacles like complex logic and unpredictable dependencies make writing valuable tests difficult, but unittest.mock can help you overcome these obstacles.

Mail addresses
?subject=Python article for you&body=Understanding the Python Mock Object Library on Real Python https://realpython.com/python-mock-library/

Opengraph URL: https://realpython.com/python-mock-library/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "Understanding the Python Mock Object Library",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/python-mock-library/",
    "lastReviewed": "2025-01-18",
    "author": {
      "@type": "Person",
      "name": "Alex Ronquillo",
      "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_0116.f88cbfca15da.jpg",
      "url": "https://realpython.com/team/aronquillo/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Aldren Santos",
        "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
        "url": "https://realpython.com/team/asantos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Brenda Weleschuk",
        "image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
        "url": "https://realpython.com/team/bweleschuk/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "David Amos",
        "image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/me-small.f5f49f1c48e1.jpg",
        "url": "https://realpython.com/team/damos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Geir Arne Hjelle",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
        "url": "https://realpython.com/team/gahjelle/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Joanna Jablonski",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/jjablonksi-avatar.e37c4f83308e.jpg",
        "url": "https://realpython.com/team/jjablonski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Martin Breuss",
        "image": "https://realpython.com/cdn-cgi/image/width=456,height=456,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/martin_breuss_python_square.efb2b07faf9f.jpg",
        "url": "https://realpython.com/team/mbreuss/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2025-01-18T14:00:00+00:00",
  "dateModified": "2025-01-18T14:09:23.501827+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Alex Ronquillo",
    "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_0116.f88cbfca15da.jpg",
    "url": "https://realpython.com/team/aronquillo/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "In this tutorial, you'll learn how to use the Python mock object library, unittest.mock, to create and use mock objects to improve your tests. Obstacles like complex logic and unpredictable dependencies make writing valuable tests difficult, but unittest.mock can help you overcome these obstacles.",
  "hasPart": {
    "@type": "FAQPage",
    "mainEntity": [
      {
        "@type": "Question",
        "name": "What is a mock object in Python?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "

A mock object in Python is a simulated object that mimics the behavior of real objects in a controlled way, allowing you to test parts of your code without relying on actual external dependencies.

" } }, { "@type": "Question", "name": "How do you create a mock object in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You create a mock object in Python by using the Mock class from the unittest.mock library, which can be configured to imitate real objects and capture their usage data during tests.

" } }, { "@type": "Question", "name": "What is the difference between Mock and MagicMock?", "acceptedAnswer": { "@type": "Answer", "text": "

The main difference between Mock and MagicMock is that MagicMock is a subclass of Mock that has default implementations for most magic methods, making it more suitable for use cases involving special methods.

" } }, { "@type": "Question", "name": "What is the purpose of the patch() function in Python mocking?", "acceptedAnswer": { "@type": "Answer", "text": "

The patch() function in Python mocking is used to temporarily replace real objects with mock objects within a specified scope, allowing you to control the behavior of dependencies during tests.

" } }, { "@type": "Question", "name": "What is the difference between Mock and patch()?", "acceptedAnswer": { "@type": "Answer", "text": "

Mock is used to create mock objects, while patch() is a function that temporarily replaces an object in a given module with a mock during a test. This allows you to control the behavior and scope of the mock.

" } }, { "@type": "Question", "name": "How do you write a mock test in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

To write a mock test in Python, you use the unittest.mock library to create mock objects and substitute them for real objects in your code, allowing you to test how your code interacts with those objects.

" } }, { "@type": "Question", "name": "How can you assert that a mock method was called with specific arguments?", "acceptedAnswer": { "@type": "Answer", "text": "

You can assert that a mock method was called with specific arguments by using the .assert_called_with(*args, **kwargs) method, which checks if the mock was called with the expected arguments.

" } }, { "@type": "Question", "name": "What are common problems when using mock objects in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

Common problems with mock objects include interface changes and misspellings leading to irrelevant tests.

" } }, { "@type": "Question", "name": "How can you ensure a mock object only has specific methods or attributes?", "acceptedAnswer": { "@type": "Answer", "text": "

You can ensure a mock object only has specific methods or attributes by passing a specification to the spec parameter when creating the mock. This restricts the mock to only have those defined methods and attributes.

" } } ] } }

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg
og:imagehttps://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg
twitter:creator@realpython
og:typearticle

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/python-mock-library/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/python-mock-library/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Fpython-mock-library%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics
Intermediatehttps://realpython.com/search?level=intermediate
Advancedhttps://realpython.com/search?level=advanced
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/python-mock-library/#toc
What Is Mocking?https://realpython.com/python-mock-library/#what-is-mocking
The Python Mock Libraryhttps://realpython.com/python-mock-library/#the-python-mock-library
The Mock Objecthttps://realpython.com/python-mock-library/#the-mock-object
Understanding Lazy Attributes and Methodshttps://realpython.com/python-mock-library/#understanding-lazy-attributes-and-methods
Leveraging Assertions and Inspectionhttps://realpython.com/python-mock-library/#leveraging-assertions-and-inspection
Managing a Mock’s Return Valuehttps://realpython.com/python-mock-library/#managing-a-mocks-return-value
Managing a Mock’s Side Effectshttps://realpython.com/python-mock-library/#managing-a-mocks-side-effects
Configuring Your Mockhttps://realpython.com/python-mock-library/#configuring-your-mock
The patch() Functionhttps://realpython.com/python-mock-library/#the-patch-function
Using patch() as a Decoratorhttps://realpython.com/python-mock-library/#using-patch-as-a-decorator
Using patch() as a Context Managerhttps://realpython.com/python-mock-library/#using-patch-as-a-context-manager
Patching an Object’s Attributeshttps://realpython.com/python-mock-library/#patching-an-objects-attributes
Knowing Where to Patchhttps://realpython.com/python-mock-library/#knowing-where-to-patch
Common Mocking Problemshttps://realpython.com/python-mock-library/#common-mocking-problems
Changes to Object Interfaces and Misspellingshttps://realpython.com/python-mock-library/#changes-to-object-interfaces-and-misspellings
Changes to External Dependencieshttps://realpython.com/python-mock-library/#changes-to-external-dependencies
Avoiding Common Problems Using Specificationshttps://realpython.com/python-mock-library/#avoiding-common-problems-using-specifications
Conclusionhttps://realpython.com/python-mock-library/#conclusion
Frequently Asked Questionshttps://realpython.com/python-mock-library/#frequently-asked-questions
https://realpython.com/feedback/survey/article/python-mock-library/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/python-mock-library/disliked/?from=article-sidebar
Improve Your Tests With the Python Mock Object Library 1h 37m · 32 lessons https://realpython.com/courses/python-mock-object-library/
Alex Ronquillohttps://realpython.com/python-mock-library/#author
https://realpython.com/python-mock-library/#reader-comments
intermediatehttps://realpython.com/tutorials/intermediate/
testinghttps://realpython.com/tutorials/testing/
What Is Mocking?https://realpython.com/python-mock-library/#what-is-mocking
The Python Mock Libraryhttps://realpython.com/python-mock-library/#the-python-mock-library
The Mock Objecthttps://realpython.com/python-mock-library/#the-mock-object
Understanding Lazy Attributes and Methodshttps://realpython.com/python-mock-library/#understanding-lazy-attributes-and-methods
Leveraging Assertions and Inspectionhttps://realpython.com/python-mock-library/#leveraging-assertions-and-inspection
Managing a Mock’s Return Valuehttps://realpython.com/python-mock-library/#managing-a-mocks-return-value
Managing a Mock’s Side Effectshttps://realpython.com/python-mock-library/#managing-a-mocks-side-effects
Configuring Your Mockhttps://realpython.com/python-mock-library/#configuring-your-mock
The patch() Functionhttps://realpython.com/python-mock-library/#the-patch-function
Using patch() as a Decoratorhttps://realpython.com/python-mock-library/#using-patch-as-a-decorator
Using patch() as a Context Managerhttps://realpython.com/python-mock-library/#using-patch-as-a-context-manager
Patching an Object’s Attributeshttps://realpython.com/python-mock-library/#patching-an-objects-attributes
Knowing Where to Patchhttps://realpython.com/python-mock-library/#knowing-where-to-patch
Common Mocking Problemshttps://realpython.com/python-mock-library/#common-mocking-problems
Changes to Object Interfaces and Misspellingshttps://realpython.com/python-mock-library/#changes-to-object-interfaces-and-misspellings
Changes to External Dependencieshttps://realpython.com/python-mock-library/#changes-to-external-dependencies
Avoiding Common Problems Using Specificationshttps://realpython.com/python-mock-library/#avoiding-common-problems-using-specifications
Conclusionhttps://realpython.com/python-mock-library/#conclusion
Frequently Asked Questionshttps://realpython.com/python-mock-library/#frequently-asked-questions
Remove adshttps://realpython.com/account/join/
Improve Your Tests With the Python Mock Object Libraryhttps://realpython.com/courses/python-mock-object-library/
Click here to download the free sample codehttps://realpython.com/bonus/python-mock-library-code/
https://realpython.com/quizzes/python-mock-library/
Understanding the Python Mock Object Libraryhttps://realpython.com/quizzes/python-mock-library/
https://realpython.com/python-mock-library/#what-is-mocking
mock objecthttps://en.wikipedia.org/wiki/Mock_object
testing environmenthttps://realpython.com/python-testing/
improve the quality of your testshttps://realpython.com/python-cli-testing/#mocks
HTTP requestshttps://realpython.com/python-requests/
Replacing the actual request with a mock objecthttps://realpython.com/testing-third-party-apis-with-mocks/
code coveragehttps://en.wikipedia.org/wiki/Code_coverage
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-mock-library/#the-python-mock-library
unittest.mockhttps://docs.python.org/3/library/unittest.mock.html
mockhttps://pypi.org/project/mock/
piphttps://realpython.com/what-is-pip/
virtual environmenthttps://realpython.com/python-virtual-environments-a-primer/
decoratorhttps://realpython.com/primer-on-python-decorators/
context managerhttps://realpython.com/python-with-statement/
https://realpython.com/python-mock-library/#the-mock-object
https://realpython.com/python-mock-library/#understanding-lazy-attributes-and-methods
attributeshttps://docs.python.org/3/library/unittest.mock.html#quick-guide
real dumps()https://realpython.com/python-json/#serializing-json
recursivelyhttps://realpython.com/python-recursion/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-mock-library/#leveraging-assertions-and-inspection
assertionshttps://realpython.com/python-assert-statement/
positional argumenthttps://realpython.com/defining-your-own-python-function/#positional-arguments
keyword argumenthttps://realpython.com/defining-your-own-python-function/#keyword-arguments
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-mock-library/#managing-a-mocks-return-value
return valuehttps://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.return_value
Python’s datetime libraryhttps://realpython.com/python-datetime/
freezegunhttps://github.com/spulec/freezegun
namespacehttps://realpython.com/python-namespaces-scope/
later onhttps://realpython.com/python-mock-library/#using-patch-as-a-decorator
https://realpython.com/python-mock-library/#managing-a-mocks-side-effects
side effectshttps://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.side_effect
Nonehttps://realpython.com/null-in-python/
unittesthttps://docs.python.org/3/library/unittest.html
print()https://realpython.com/python-print/
print()https://realpython.com/courses/python-print/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-mock-library/#configuring-your-mock
createhttps://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock
.configure_mock()https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.configure_mock
leading underscorehttps://realpython.com/python-double-underscore/
unpacking a dictionaryhttps://realpython.com/python-kwargs-and-args/#unpacking-with-the-asterisk-operators
https://realpython.com/python-mock-library/#the-patch-function
patch()https://docs.python.org/3/library/unittest.mock.html#patch
https://realpython.com/python-mock-library/#using-patch-as-a-decorator
decoratorhttps://realpython.com/primer-on-python-decorators/
Monkey patchinghttps://en.wikipedia.org/wiki/Monkey_patch
MagicMockhttps://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock
magic methodshttps://realpython.com/python-magic-methods/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-mock-library/#using-patch-as-a-context-manager
context managerhttps://realpython.com/python-with-statement/
https://realpython.com/python-mock-library/#patching-an-objects-attributes
patch.object()https://docs.python.org/3/library/unittest.mock.html#patch-object
patch.dict()https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.dict
https://realpython.com/python-mock-library/#knowing-where-to-patch
good rule of thumbhttps://docs.python.org/3/library/unittest.mock.html#where-to-patch
__main__https://realpython.com/if-name-main-python/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-mock-library/#common-mocking-problems
https://realpython.com/python-mock-library/#changes-to-object-interfaces-and-misspellings
interfacehttps://realpython.com/python-interface/
a list of common misspellingshttps://github.com/python/cpython/blob/55596ae0446e40f47e2a28b8897fe9530c32a19a/Lib/unittest/mock.py#L692
informative error messagehttps://realpython.com/python312-error-messages/
https://realpython.com/python-mock-library/#changes-to-external-dependencies
https://realpython.com/python-mock-library/#avoiding-common-problems-using-specifications
creates attributes and methods lazilyhttps://realpython.com/python-mock-library/#understanding-lazy-attributes-and-methods
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-mock-library/#conclusion
unittesthttps://realpython.com/python-unittest/
unittest.mockhttps://docs.python.org/3/library/unittest.mock.html
tests in Pythonhttps://realpython.com/python-testing/
Click here to download the free sample codehttps://realpython.com/bonus/python-mock-library-code/
https://realpython.com/quizzes/python-mock-library/
Understanding the Python Mock Object Libraryhttps://realpython.com/quizzes/python-mock-library/
https://realpython.com/python-mock-library/#frequently-asked-questions
https://realpython.com/feedback/survey/article/python-mock-library/liked/?from=article-footer
https://realpython.com/feedback/survey/article/python-mock-library/disliked/?from=article-footer
Improve Your Tests With the Python Mock Object Libraryhttps://realpython.com/courses/python-mock-object-library/
https://realpython.com/team/aronquillo/
» More about Alexhttps://realpython.com/team/aronquillo/
https://realpython.com/team/asantos/
Aldrenhttps://realpython.com/team/asantos/
https://realpython.com/team/bweleschuk/
Brendahttps://realpython.com/team/bweleschuk/
https://realpython.com/team/damos/
Davidhttps://realpython.com/team/damos/
https://realpython.com/team/gahjelle/
Geir Arnehttps://realpython.com/team/gahjelle/
https://realpython.com/team/jjablonski/
Joannahttps://realpython.com/team/jjablonski/
https://realpython.com/team/mbreuss/
Martinhttps://realpython.com/team/mbreuss/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-mock-library
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-mock-library
https://realpython.com/feedback/survey/article/python-mock-library/liked/?from=article-comments
https://realpython.com/feedback/survey/article/python-mock-library/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fpython-mock-library%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20Understanding%20the%20Python%20Mock%20Object%20Library&url=https%3A%2F%2Frealpython.com%2Fpython-mock-library%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20Understanding%20the%20Python%20Mock%20Object%20Library%20https%3A%2F%2Frealpython.com%2Fpython-mock-library%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fpython-mock-library%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
intermediatehttps://realpython.com/tutorials/intermediate/
testinghttps://realpython.com/tutorials/testing/
Improve Your Tests With the Python Mock Object Libraryhttps://realpython.com/courses/python-mock-object-library/?utm_source=realpython&utm_medium=web&utm_campaign=related-course&utm_content=python-mock-library
Python's unittest: Writing Unit Tests for Your Codehttps://realpython.com/python-unittest/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-mock-library
Getting Started With Testing in Pythonhttps://realpython.com/python-testing/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-mock-library
Build Enumerations of Constants With Python's Enumhttps://realpython.com/python-enum/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-mock-library
Effective Python Testing With pytesthttps://realpython.com/pytest-python-testing/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-mock-library
Primer on Python Decoratorshttps://realpython.com/primer-on-python-decorators/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-mock-library
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-mock-library%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-mock-library%2F
Sign-Inhttps://realpython.com/account/login/?next=/python-mock-library/
Start Herehttps://realpython.com/start-here/
Learning Resourceshttps://realpython.com/search
Code Mentorhttps://realpython.com/mentor/
Python Referencehttps://realpython.com/ref/
Python Cheat Sheethttps://realpython.com/cheatsheets/python/
Support Centerhttps://support.realpython.com/
Learning Pathshttps://realpython.com/learning-paths/
Quizzes & Exerciseshttps://realpython.com/quizzes/
Browse Topicshttps://realpython.com/tutorials/all/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.