{ "info": { "author": "Tim Savage", "author_email": "tim@savage.company", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "##########\nAsync Mock\n##########\n\nAwaitable mocks for async code.\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/ambv/black\n :alt: Once you go Black...\n\n.. image:: https://travis-ci.org/timsavage/asyncmock.svg?branch=master\n :target: https://travis-ci.org/timsavage/asyncmock\n\n.. image:: https://img.shields.io/pypi/l/asyncmock.svg\n :target: https://pypi.python.org/pypi/asyncmock\n\n.. image:: https://img.shields.io/pypi/pyversions/asyncmock.svg\n :target: https://pypi.python.org/pypi/asyncmock\n\n.. image:: https://img.shields.io/pypi/status/asyncmock.svg\n :target: https://pypi.python.org/pypi/asyncmock\n\n.. image:: https://img.shields.io/pypi/implementation/asyncmock.svg\n :target: https://pypi.python.org/pypi/asyncmock\n\nThe package specifically only extends mock_ and not any other part of unittest.\n\n.. _mock: https://mock.readthedocs.io/en/latest/\n\n\nInstallation\n============\n\nInstall using *pip*:\n\n.. code-block:: bash\n\n pip install asyncmock\n\n\nUsage\n=====\n\nAsync Mock is a drop in replacement for a `Mock` object eg:\n\n.. code-block:: python\n\n my_mock = AsyncMock()\n\n await my_mock(\"foo\", bar=123)\n\n my_mock.assert_called_with(\"foo\", bar=123)\n\n\nThis also works with nested methods:\n\n.. code-block:: python\n\n my_mock = AsyncMock()\n\n await my_mock.my_method(\"foo\", bar=123)\n\n my_mock.my_method.assert_called_with(\"foo\", bar=123)\n\n\nSide effects and return values can also be awaited.\n\nIncluding a non-awaitable item:\n\n.. code-block:: python\n\n my_mock = AsyncMock()\n\n my_mock.my_method.not_async = True\n my_mock.my_method(\"foo\", bar=123)\n\n\nThe `not_async` option can also be provided as an init argument. The `not_async` \nargument is not inherited by sub-mocks.\n\n\npytest Example\n==============\n\nThese examples use pytest_ along with the pytest-asyncio_ plugin.\n\n.. _pytest: https://docs.pytest.org/en/latest/\n.. _pytest-asyncio: https://github.com/pytest-dev/pytest-asyncio\n\n\nGenerating an exception:\n\n.. code-block:: python\n\n @pytest.mark.asyncio\n async def test_raise_exception():\n my_mock = AsyncMock(side_effect=KeyError)\n\n with pytest.raises(KeyError):\n await my_mock()\n\n my_mock.assert_called()\n\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/timsavage/asyncmock", "keywords": "testing,mock,asyncio", "license": "BSD-3-Clause", "maintainer": "", "maintainer_email": "", "name": "asyncmock", "package_url": "https://pypi.org/project/asyncmock/", "platform": "any", "project_url": "https://pypi.org/project/asyncmock/", "project_urls": { "Homepage": "https://github.com/timsavage/asyncmock" }, "release_url": "https://pypi.org/project/asyncmock/0.4.1/", "requires_dist": [ "mock" ], "requires_python": ">=3.6", "summary": "Extension to the standard mock framework to support support async", "version": "0.4.1" }, "last_serial": 5986884, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "ba4532536a277a2514ac9d27914bfc33", "sha256": "c0403e1e3b2a8f3ef2e9d7bbf5dbb9f12394e5e4f2c2328d6577a65a2bcc8f8b" }, "downloads": -1, "filename": "asyncmock-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ba4532536a277a2514ac9d27914bfc33", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 4152, "upload_time": "2019-07-18T13:21:09", "url": "https://files.pythonhosted.org/packages/db/ca/06694f4bc64834373856f44d191ddfff03d3e65c40a2b31083b091dcfb4f/asyncmock-0.2.0-py3-none-any.whl" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "69f3d5d039d2ca58d776a40953739d1a", "sha256": "1e1db94bda037adef2a80d3bd64d842b0bc00cb8f170032fd1df3b64dbc3f438" }, "downloads": -1, "filename": "asyncmock-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "69f3d5d039d2ca58d776a40953739d1a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 3997, "upload_time": "2019-07-18T13:56:49", "url": "https://files.pythonhosted.org/packages/94/2f/aae78bb1c3d1493885f097e3a56be97fcb85cb64110c0a6b29d92bc2e6b0/asyncmock-0.3.0-py3-none-any.whl" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "8a4ce5a68fe34f6ec0b416553e35a7e7", "sha256": "39ed13ac9525db595a3d4c52ae6ecf8df789953e4d64cf6e5e0c8d21524a6273" }, "downloads": -1, "filename": "asyncmock-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8a4ce5a68fe34f6ec0b416553e35a7e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 4282, "upload_time": "2019-07-18T15:22:34", "url": "https://files.pythonhosted.org/packages/82/ae/edc260f5f2a972aff5c43644842cf89e883ad484aba78c608426fb9b82f2/asyncmock-0.4.0-py3-none-any.whl" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "bed2e80aa97467839f5017dc97799c29", "sha256": "db12e484fb37b7d6cecc496f15515ecb1bf6ff03ce1be0ec4789b14454a82409" }, "downloads": -1, "filename": "asyncmock-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "bed2e80aa97467839f5017dc97799c29", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 4317, "upload_time": "2019-10-16T23:36:39", "url": "https://files.pythonhosted.org/packages/1b/24/77a8ffd556714553aba24ea99c84f5b088d82b0bbd7e95d6d1cf99ee8938/asyncmock-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "37f63f7c45ea0f468f04e9842c6a34d6", "sha256": "34fb83b1b9ebe5b2a410af09889a5fe316ba9cc7a2a2605c63157ea0a1425d28" }, "downloads": -1, "filename": "asyncmock-0.4.1.tar.gz", "has_sig": false, "md5_digest": "37f63f7c45ea0f468f04e9842c6a34d6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3094, "upload_time": "2019-10-16T23:36:41", "url": "https://files.pythonhosted.org/packages/b4/5a/7c57d4275044f433bd11daca1e9bc80711de999013e566493e18d8923a18/asyncmock-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bed2e80aa97467839f5017dc97799c29", "sha256": "db12e484fb37b7d6cecc496f15515ecb1bf6ff03ce1be0ec4789b14454a82409" }, "downloads": -1, "filename": "asyncmock-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "bed2e80aa97467839f5017dc97799c29", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 4317, "upload_time": "2019-10-16T23:36:39", "url": "https://files.pythonhosted.org/packages/1b/24/77a8ffd556714553aba24ea99c84f5b088d82b0bbd7e95d6d1cf99ee8938/asyncmock-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "37f63f7c45ea0f468f04e9842c6a34d6", "sha256": "34fb83b1b9ebe5b2a410af09889a5fe316ba9cc7a2a2605c63157ea0a1425d28" }, "downloads": -1, "filename": "asyncmock-0.4.1.tar.gz", "has_sig": false, "md5_digest": "37f63f7c45ea0f468f04e9842c6a34d6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3094, "upload_time": "2019-10-16T23:36:41", "url": "https://files.pythonhosted.org/packages/b4/5a/7c57d4275044f433bd11daca1e9bc80711de999013e566493e18d8923a18/asyncmock-0.4.1.tar.gz" } ] }