pytest-mock


Namepytest-mock JSON
Version 3.14.0 PyPI version JSON
download
home_pageNone
SummaryThin-wrapper around the mock package for easier use with pytest
upload_time2024-03-21 22:14:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
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.8",
    "maintainer_email": null,
    "keywords": "pytest, mock",
    "author": null,
    "author_email": "Bruno Oliveira <nicoddemus@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c6/90/a955c3ab35ccd41ad4de556596fa86685bf4fc5ffcc62d22d856cfd4e29a/pytest-mock-3.14.0.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.14.0",
    "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": "",
            "digests": {
                "blake2b_256": "f23bb26f90f74e2986a82df6e7ac7e319b8ea7ccece1caec9f8ab6104dc70603",
                "md5": "d61798dcd70655d6e2b70937e39d34ad",
                "sha256": "0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f"
            },
            "downloads": -1,
            "filename": "pytest_mock-3.14.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d61798dcd70655d6e2b70937e39d34ad",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9863,
            "upload_time": "2024-03-21T22:14:02",
            "upload_time_iso_8601": "2024-03-21T22:14:02.694718Z",
            "url": "https://files.pythonhosted.org/packages/f2/3b/b26f90f74e2986a82df6e7ac7e319b8ea7ccece1caec9f8ab6104dc70603/pytest_mock-3.14.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c690a955c3ab35ccd41ad4de556596fa86685bf4fc5ffcc62d22d856cfd4e29a",
                "md5": "c22f3c24300091f503258d1ba5159551",
                "sha256": "2719255a1efeceadbc056d6bf3df3d1c5015530fb40cf347c0f9afac88410bd0"
            },
            "downloads": -1,
            "filename": "pytest-mock-3.14.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c22f3c24300091f503258d1ba5159551",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 32814,
            "upload_time": "2024-03-21T22:14:04",
            "upload_time_iso_8601": "2024-03-21T22:14:04.964480Z",
            "url": "https://files.pythonhosted.org/packages/c6/90/a955c3ab35ccd41ad4de556596fa86685bf4fc5ffcc62d22d856cfd4e29a/pytest-mock-3.14.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-21 22:14:04",
    "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: 0.39617s