10 best Python Mock libraries in 2024

share link

by marketing.admin@openweaver.com dot icon Updated: Mar 12, 2023

technology logo
technology logo

Guide Kit Guide Kit  

Mock objects make it possible to write automated tests for code that depends on external services or resources. The most common scenario is when a web application depends on some kind of database. Mocking the database allows you to write tests that check that code that uses the database is operating correctly without actually performing any database operations (which may well be slow or impossible). In this kit, we will discuss the top 8 Python Mock Open Source libraries that you can use in your testing project. moto - easily mock out tests based on AWS infrastructure; responses - A utility for mocking out the Python Requests library; vcrpy - Automatically mock your HTTP interactions.

motoby spulec

Python doticonstar image 6558 doticonVersion:Currentdoticon
License: Permissive (Apache-2.0)

A library that allows you to easily mock out tests based on AWS infrastructure.

Support
    Quality
      Security
        License
          Reuse

            motoby spulec

            Python doticon star image 6558 doticonVersion:Currentdoticon License: Permissive (Apache-2.0)

            A library that allows you to easily mock out tests based on AWS infrastructure.
            Support
              Quality
                Security
                  License
                    Reuse

                      responsesby getsentry

                      Python doticonstar image 3895 doticonVersion:0.23.1doticon
                      License: Permissive (Apache-2.0)

                      A utility for mocking out the Python Requests library.

                      Support
                        Quality
                          Security
                            License
                              Reuse

                                responsesby getsentry

                                Python doticon star image 3895 doticonVersion:0.23.1doticon License: Permissive (Apache-2.0)

                                A utility for mocking out the Python Requests library.
                                Support
                                  Quality
                                    Security
                                      License
                                        Reuse

                                          vcrpyby kevin1024

                                          Python doticonstar image 2421 doticonVersion:v4.3.1doticon
                                          License: Permissive (MIT)

                                          Automatically mock your HTTP interactions to simplify and speed up testing

                                          Support
                                            Quality
                                              Security
                                                License
                                                  Reuse

                                                    vcrpyby kevin1024

                                                    Python doticon star image 2421 doticonVersion:v4.3.1doticon License: Permissive (MIT)

                                                    Automatically mock your HTTP interactions to simplify and speed up testing
                                                    Support
                                                      Quality
                                                        Security
                                                          License
                                                            Reuse

                                                              HTTPrettyby gabrielfalcao

                                                              Python doticonstar image 2039 doticonVersion:Currentdoticon
                                                              License: Permissive (MIT)

                                                              Intercept HTTP requests at the Python socket level. Fakes the whole socket module

                                                              Support
                                                                Quality
                                                                  Security
                                                                    License
                                                                      Reuse

                                                                        HTTPrettyby gabrielfalcao

                                                                        Python doticon star image 2039 doticonVersion:Currentdoticon License: Permissive (MIT)

                                                                        Intercept HTTP requests at the Python socket level. Fakes the whole socket module
                                                                        Support
                                                                          Quality
                                                                            Security
                                                                              License
                                                                                Reuse

                                                                                  pytest-mockby pytest-dev

                                                                                  Python doticonstar image 1605 doticonVersion:v3.10.0doticon
                                                                                  License: Permissive (MIT)

                                                                                  Thin-wrapper around the mock package for easier use with pytest

                                                                                  Support
                                                                                    Quality
                                                                                      Security
                                                                                        License
                                                                                          Reuse

                                                                                            pytest-mockby pytest-dev

                                                                                            Python doticon star image 1605 doticonVersion:v3.10.0doticon License: Permissive (MIT)

                                                                                            Thin-wrapper around the mock package for easier use with pytest
                                                                                            Support
                                                                                              Quality
                                                                                                Security
                                                                                                  License
                                                                                                    Reuse

                                                                                                      mongomockby mongomock

                                                                                                      Python doticonstar image 841 doticonVersion:4.1.2doticon
                                                                                                      License: Others (Non-SPDX)

                                                                                                      Small library for mocking pymongo collection objects for testing purposes

                                                                                                      Support
                                                                                                        Quality
                                                                                                          Security
                                                                                                            License
                                                                                                              Reuse

                                                                                                                mongomockby mongomock

                                                                                                                Python doticon star image 841 doticonVersion:4.1.2doticon License: Others (Non-SPDX)

                                                                                                                Small library for mocking pymongo collection objects for testing purposes
                                                                                                                Support
                                                                                                                  Quality
                                                                                                                    Security
                                                                                                                      License
                                                                                                                        Reuse

                                                                                                                          requests-mockby jamielennox

                                                                                                                          Python doticonstar image 364 doticonVersion:1.10.0doticon
                                                                                                                          License: Permissive (Apache-2.0)

                                                                                                                          Mocked responses for the requests library

                                                                                                                          Support
                                                                                                                            Quality
                                                                                                                              Security
                                                                                                                                License
                                                                                                                                  Reuse

                                                                                                                                    requests-mockby jamielennox

                                                                                                                                    Python doticon star image 364 doticonVersion:1.10.0doticon License: Permissive (Apache-2.0)

                                                                                                                                    Mocked responses for the requests library
                                                                                                                                    Support
                                                                                                                                      Quality
                                                                                                                                        Security
                                                                                                                                          License
                                                                                                                                            Reuse
                                                                                                                                              Python doticonstar image 257 doticonVersion:v2.2.0doticon
                                                                                                                                              License: Permissive (MIT)

                                                                                                                                              A library for mocking django queryset functions in memory for testing

                                                                                                                                              Support
                                                                                                                                                Quality
                                                                                                                                                  Security
                                                                                                                                                    License
                                                                                                                                                      Reuse

                                                                                                                                                        django-mock-queriesby stphivos

                                                                                                                                                        Python doticon star image 257 doticonVersion:v2.2.0doticon License: Permissive (MIT)

                                                                                                                                                        A library for mocking django queryset functions in memory for testing
                                                                                                                                                        Support
                                                                                                                                                          Quality
                                                                                                                                                            Security
                                                                                                                                                              License
                                                                                                                                                                Reuse
                                                                                                                                                                  Python doticonstar image 105 doticonVersion:Currentdoticon
                                                                                                                                                                  License: Permissive (MIT)

                                                                                                                                                                  Mock EC2 metadata service that can run on a developer machine

                                                                                                                                                                  Support
                                                                                                                                                                    Quality
                                                                                                                                                                      Security
                                                                                                                                                                        License
                                                                                                                                                                          Reuse

                                                                                                                                                                            aws-mock-metadataby dump247

                                                                                                                                                                            Python doticon star image 105 doticonVersion:Currentdoticon License: Permissive (MIT)

                                                                                                                                                                            Mock EC2 metadata service that can run on a developer machine
                                                                                                                                                                            Support
                                                                                                                                                                              Quality
                                                                                                                                                                                Security
                                                                                                                                                                                  License
                                                                                                                                                                                    Reuse

                                                                                                                                                                                      mock-alchemyby rajivsarvepalli

                                                                                                                                                                                      Python doticonstar image 57 doticonVersion:v0.2.6doticon
                                                                                                                                                                                      License: Permissive (MIT)

                                                                                                                                                                                      SQLAlchemy mock helpers.

                                                                                                                                                                                      Support
                                                                                                                                                                                        Quality
                                                                                                                                                                                          Security
                                                                                                                                                                                            License
                                                                                                                                                                                              Reuse

                                                                                                                                                                                                mock-alchemyby rajivsarvepalli

                                                                                                                                                                                                Python doticon star image 57 doticonVersion:v0.2.6doticon License: Permissive (MIT)

                                                                                                                                                                                                SQLAlchemy mock helpers.
                                                                                                                                                                                                Support
                                                                                                                                                                                                  Quality
                                                                                                                                                                                                    Security
                                                                                                                                                                                                      License
                                                                                                                                                                                                        Reuse

                                                                                                                                                                                                          See similar Kits and Libraries