pytest-mock


Namepytest-mock JSON
Version 3.15.1 PyPI version JSON
download
home_pageNone
SummaryThin-wrapper around the mock package for easier use with pytest
upload_time2025-09-16 16:37:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords pytest mock
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===========
pytest-mock
===========

This plugin provides a ``mocker`` fixture which is a thin-wrapper around the patching API
provided by the `mock package <http://pypi.python.org/pypi/mock>`_:

.. code-block:: python

    import os

    class UnixFS:

        @staticmethod
        def rm(filename):
            os.remove(filename)

    def test_unix_fs(mocker):
        mocker.patch('os.remove')
        UnixFS.rm('file')
        os.remove.assert_called_once_with('file')


Besides undoing the mocking automatically after the end of the test, it also provides other
nice utilities such as ``spy`` and ``stub``, and uses pytest introspection when
comparing calls.

|python| |version| |anaconda| |docs| |ci| |coverage| |black| |pre-commit|

.. |version| image:: http://img.shields.io/pypi/v/pytest-mock.svg
  :target: https://pypi.python.org/pypi/pytest-mock

.. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-mock.svg
    :target: https://anaconda.org/conda-forge/pytest-mock

.. |ci| image:: https://github.com/pytest-dev/pytest-mock/workflows/test/badge.svg
  :target: https://github.com/pytest-dev/pytest-mock/actions

.. |coverage| image:: https://coveralls.io/repos/github/pytest-dev/pytest-mock/badge.svg?branch=master
  :target: https://coveralls.io/github/pytest-dev/pytest-mock?branch=master

.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg
  :target: https://pypi.python.org/pypi/pytest-mock/

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
  :target: https://github.com/ambv/black

.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest-mock/master.svg
   :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest-mock/master

.. |docs| image:: https://readthedocs.org/projects/pytest-mock/badge/?version=latest
   :target: https://pytest-mock.readthedocs.io/en/latest/?badge=latest


`Professionally supported pytest-mock is available <https://tidelift.com/subscription/pkg/pypi-pytest_mock?utm_source=pypi-pytest-mock&utm_medium=referral&utm_campaign=readme>`_.


Documentation
=============

For full documentation, please see https://pytest-mock.readthedocs.io/en/latest.

License
=======

Distributed under the terms of the `MIT`_ license.


.. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytest-mock",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "pytest, mock",
    "author": null,
    "author_email": "Bruno Oliveira <nicoddemus@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/68/14/eb014d26be205d38ad5ad20d9a80f7d201472e08167f0bb4361e251084a9/pytest_mock-3.15.1.tar.gz",
    "platform": null,
    "description": "===========\npytest-mock\n===========\n\nThis plugin provides a ``mocker`` fixture which is a thin-wrapper around the patching API\nprovided by the `mock package <http://pypi.python.org/pypi/mock>`_:\n\n.. code-block:: python\n\n    import os\n\n    class UnixFS:\n\n        @staticmethod\n        def rm(filename):\n            os.remove(filename)\n\n    def test_unix_fs(mocker):\n        mocker.patch('os.remove')\n        UnixFS.rm('file')\n        os.remove.assert_called_once_with('file')\n\n\nBesides undoing the mocking automatically after the end of the test, it also provides other\nnice utilities such as ``spy`` and ``stub``, and uses pytest introspection when\ncomparing calls.\n\n|python| |version| |anaconda| |docs| |ci| |coverage| |black| |pre-commit|\n\n.. |version| image:: http://img.shields.io/pypi/v/pytest-mock.svg\n  :target: https://pypi.python.org/pypi/pytest-mock\n\n.. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-mock.svg\n    :target: https://anaconda.org/conda-forge/pytest-mock\n\n.. |ci| image:: https://github.com/pytest-dev/pytest-mock/workflows/test/badge.svg\n  :target: https://github.com/pytest-dev/pytest-mock/actions\n\n.. |coverage| image:: https://coveralls.io/repos/github/pytest-dev/pytest-mock/badge.svg?branch=master\n  :target: https://coveralls.io/github/pytest-dev/pytest-mock?branch=master\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg\n  :target: https://pypi.python.org/pypi/pytest-mock/\n\n.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n  :target: https://github.com/ambv/black\n\n.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest-mock/master.svg\n   :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest-mock/master\n\n.. |docs| image:: https://readthedocs.org/projects/pytest-mock/badge/?version=latest\n   :target: https://pytest-mock.readthedocs.io/en/latest/?badge=latest\n\n\n`Professionally supported pytest-mock is available <https://tidelift.com/subscription/pkg/pypi-pytest_mock?utm_source=pypi-pytest-mock&utm_medium=referral&utm_campaign=readme>`_.\n\n\nDocumentation\n=============\n\nFor full documentation, please see https://pytest-mock.readthedocs.io/en/latest.\n\nLicense\n=======\n\nDistributed under the terms of the `MIT`_ license.\n\n\n.. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Thin-wrapper around the mock package for easier use with pytest",
    "version": "3.15.1",
    "project_urls": {
        "Changelog": "https://pytest-mock.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://pytest-mock.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/pytest-dev/pytest-mock/",
        "Source": "https://github.com/pytest-dev/pytest-mock/",
        "Tracker": "https://github.com/pytest-dev/pytest-mock/issues"
    },
    "split_keywords": [
        "pytest",
        " mock"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5acc06253936f4a7fa2e0f48dfe6d851d9c56df896a9ab09ac019d70b760619c",
                "md5": "835fac1e7937671e1d94f8535b92e56b",
                "sha256": "0a25e2eb88fe5168d535041d09a4529a188176ae608a6d249ee65abc0949630d"
            },
            "downloads": -1,
            "filename": "pytest_mock-3.15.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "835fac1e7937671e1d94f8535b92e56b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 10095,
            "upload_time": "2025-09-16T16:37:25",
            "upload_time_iso_8601": "2025-09-16T16:37:25.734966Z",
            "url": "https://files.pythonhosted.org/packages/5a/cc/06253936f4a7fa2e0f48dfe6d851d9c56df896a9ab09ac019d70b760619c/pytest_mock-3.15.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6814eb014d26be205d38ad5ad20d9a80f7d201472e08167f0bb4361e251084a9",
                "md5": "5fb976ed4303e4f8132ed2367e297e31",
                "sha256": "1849a238f6f396da19762269de72cb1814ab44416fa73a8686deac10b0d87a0f"
            },
            "downloads": -1,
            "filename": "pytest_mock-3.15.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5fb976ed4303e4f8132ed2367e297e31",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 34036,
            "upload_time": "2025-09-16T16:37:27",
            "upload_time_iso_8601": "2025-09-16T16:37:27.081129Z",
            "url": "https://files.pythonhosted.org/packages/68/14/eb014d26be205d38ad5ad20d9a80f7d201472e08167f0bb4361e251084a9/pytest_mock-3.15.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-16 16:37:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pytest-dev",
    "github_project": "pytest-mock",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-mock"
}
        
Elapsed time: 1.72073s