{ "info": { "author": "Matthew Tardiff", "author_email": "mattrix@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Testing" ], "description": "Simian |Version| |Build| |Coverage| |Health|\n============================================\n\n|Compatibility| |Implementations| |Format| |Downloads|\n\nA decorator for easily mocking out multiple dependencies by\nmonkey-patching.\n\n.. code:: python\n\n @simian.patch(module=..., external=[...], internal=[...])\n\n\nInstallation:\n\n.. code:: shell\n\n $ pip install simian\n\n\n``simian.patch`` is a convenience wrapper around `mock.patch`_ with the\nfollowing benefits:\n\n1. All patched objects are collected under a single ``master_mock``, which is\n provided to the function being decorated. Any patched target can be\n accessed by its basename (e.g., a patched ``time.sleep`` would be\n accessed in the decorated function as ``master_mock.sleep``).\n2. The patching works even if the target is imported directly (e.g., a call to\n ``sleep`` is patched the same as a call to ``time.sleep``). Simian handles\n this by reloading the module under test after applying the ``external``\n patches.\n3. Objects ``internal`` to the module under test can be patched as well. They\n are collected under the same ``master_mock`` and can be referenced in the\n same way.\n\nAfter leaving the decorated function, simian reloads the module under test\n*again*, bringing it back to its pre-patched state (although all of the\nmodule's addresses in memory have changed).\n\n\nExternal Patching\n-----------------\n\n.. code:: python\n\n #\n # my_package.my_module\n #\n\n from time import sleep\n\n\n def my_sleep(duration_secs):\n print('Sleeping for {n} seconds'.format(n=duration_secs))\n sleep(duration_secs)\n\n\n #\n # my_package.test.test_my_module\n #\n\n import simian\n from my_package import my_module\n\n\n @simian.patch(my_module, external=['time.sleep'])\n def test_my_sleep(master_mock):\n my_module.my_sleep(99)\n master_mock.sleep.assert_called_once_with(99)\n\n\nInternal Patching\n-----------------\n\nThe above example demonstrates ``external`` patching, but ``internal``\n(same-module) patching works as well. Let's extend the above example.\n\n.. code:: python\n\n #\n # my_package.my_module\n #\n\n from time import sleep\n\n\n def my_sleep(duration_secs):\n my_logger('Starting {n}-second sleep'.format(n=duration_secs))\n sleep(duration_secs)\n my_logger('Finished {n}-second sleep'.format(n=duration_secs))\n\n\n def my_logger(msg):\n print(msg)\n\n\n #\n # my_package.test.test_my_module\n #\n\n import simian\n from mock import call\n from my_package import my_module\n\n\n @simian.patch(my_module, external=['time.sleep'], internal=['my_logger'])\n def test_my_sleep(master_mock):\n my_module.my_sleep(99)\n master_mock.assert_has_calls(\n calls=[\n call.my_logger('Starting 99-second sleep'),\n call.sleep(99),\n call.my_logger('Finished 99-second sleep')],\n any_order=False)\n\n\n.. |Build| image:: https://travis-ci.org/themattrix/python-simian.svg?branch=master\n :target: https://travis-ci.org/themattrix/python-simian\n.. |Coverage| image:: https://img.shields.io/coveralls/themattrix/python-simian.svg\n :target: https://coveralls.io/r/themattrix/python-simian\n.. |Health| image:: https://landscape.io/github/themattrix/python-simian/master/landscape.svg\n :target: https://landscape.io/github/themattrix/python-simian/master\n.. |Version| image:: https://pypip.in/version/simian/badge.svg?text=version\n :target: https://pypi.python.org/pypi/simian\n.. |Downloads| image:: https://pypip.in/download/simian/badge.svg\n :target: https://pypi.python.org/pypi/simian\n.. |Compatibility| image:: https://pypip.in/py_versions/simian/badge.svg\n :target: https://pypi.python.org/pypi/simian\n.. |Implementations| image:: https://pypip.in/implementation/simian/badge.svg\n :target: https://pypi.python.org/pypi/simian\n.. |Format| image:: https://pypip.in/format/simian/badge.svg\n :target: https://pypi.python.org/pypi/simian\n.. _mock.patch: https://docs.python.org/3/library/unittest.mock.html#patch\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/themattrix/python-simian", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "simian", "package_url": "https://pypi.org/project/simian/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/simian/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/themattrix/python-simian" }, "release_url": "https://pypi.org/project/simian/2.0.0/", "requires_dist": null, "requires_python": null, "summary": "A decorator for easily mocking out multiple dependencies by monkey-patching.", "version": "2.0.0" }, "last_serial": 1359555, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "11f5d5ee48b5fd9dc60ed2729126c4ef", "sha256": "ec394a58ca09c381c6b38ab4a354cd0cd789296eda5be496ee5d34ff1814ca53" }, "downloads": -1, "filename": "simian-1.0.1.tar.gz", "has_sig": false, "md5_digest": "11f5d5ee48b5fd9dc60ed2729126c4ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2540, "upload_time": "2014-12-21T23:44:29", "url": "https://files.pythonhosted.org/packages/2e/b6/d52060284729b1cc9f693196a2dab58cdf2e609744750e59a0db8188d7f0/simian-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "093ef05b4050d92a302b8bab616a5278", "sha256": "9c057ca9d3cd1f059eb6dade48d7e691fd47f5d1adc548eec87b7d586d611b9f" }, "downloads": -1, "filename": "simian-1.0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "093ef05b4050d92a302b8bab616a5278", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3681, "upload_time": "2014-12-22T01:48:31", "url": "https://files.pythonhosted.org/packages/ac/6c/8607f6691278d3af5931c3e3acedabbc9aa859478de0de04c755375ffefc/simian-1.0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "78b0371ddcfe120a20d8e94379065a74", "sha256": "7f7a8244d5d2e1c7eb20f79d4cbe6b1b41e130aef3bd5677e521de7556bd92d9" }, "downloads": -1, "filename": "simian-1.0.2.tar.gz", "has_sig": false, "md5_digest": "78b0371ddcfe120a20d8e94379065a74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3025, "upload_time": "2014-12-22T01:48:29", "url": "https://files.pythonhosted.org/packages/51/78/17bfdebbb3ecf803dc0e9d0335974cf573617ec3fb08dfe0f1b56abc9d86/simian-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "99004b45651bdd8b3e2846f22e0f5340", "sha256": "cad88e99df01d5f07c7d8e0799c8bf2335a165d0796c69b17808c87d10343bce" }, "downloads": -1, "filename": "simian-1.0.3-py2-none-any.whl", "has_sig": false, "md5_digest": "99004b45651bdd8b3e2846f22e0f5340", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3732, "upload_time": "2014-12-22T02:43:52", "url": "https://files.pythonhosted.org/packages/cf/58/b63db3981b3ef5f9c83035f0277ae007802e2a1b4b405e4dfda12778f2e3/simian-1.0.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1ffc702a14d0130b286e7f5263a31086", "sha256": "a1084c1cfc382ffb42ff04ea03474675526d698fa6238e55a552d8767945fd83" }, "downloads": -1, "filename": "simian-1.0.3.tar.gz", "has_sig": false, "md5_digest": "1ffc702a14d0130b286e7f5263a31086", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3303, "upload_time": "2014-12-22T02:43:49", "url": "https://files.pythonhosted.org/packages/e4/4f/72b88aa116a4efc4d2498f0dcfb0ab3bb71633931919c934d8a548e908e3/simian-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "544bfacd5215d7d4a0a6d8f5033c2947", "sha256": "3e5dd57794c534a2d56886141acbe80bc7d885deddbed60ada4cd9ed9a1ebeb8" }, "downloads": -1, "filename": "simian-1.0.4-py2-none-any.whl", "has_sig": false, "md5_digest": "544bfacd5215d7d4a0a6d8f5033c2947", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3734, "upload_time": "2014-12-22T17:40:02", "url": "https://files.pythonhosted.org/packages/7a/e8/95d08e213b7cb3c9b56cae066fc8bc53231b43264b2730d7621c9324b8f9/simian-1.0.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "53f45f392dbd0e715c232989342fdb92", "sha256": "8e6bd1e72b4f49d0b890088bd40b9bb8a9b5fec82e633d094c0a95bddd8e7d0c" }, "downloads": -1, "filename": "simian-1.0.4.tar.gz", "has_sig": false, "md5_digest": "53f45f392dbd0e715c232989342fdb92", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3300, "upload_time": "2014-12-22T17:39:59", "url": "https://files.pythonhosted.org/packages/b9/26/11913bf10f9602fa0aa7d23fae689110ef140d30cd5c84afc059953f79ca/simian-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "54bda7c69e9717bfb679acc0642213f3", "sha256": "3a45a03e5f5f6859e852ab9c81ecf3478db2a6922bd18f7825d944b6db95fcf2" }, "downloads": -1, "filename": "simian-1.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "54bda7c69e9717bfb679acc0642213f3", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3747, "upload_time": "2014-12-22T22:32:04", "url": "https://files.pythonhosted.org/packages/d4/db/1b40e989675c42181c4957406d8800ba9b920f62085e0ac2e910f272bf8f/simian-1.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9ace1b0db783594932e44950318ab0b1", "sha256": "7faa0e5627bebc35f819e6b70232fcf51115d5c3bb0319f03361765831494bcb" }, "downloads": -1, "filename": "simian-1.0.5.tar.gz", "has_sig": false, "md5_digest": "9ace1b0db783594932e44950318ab0b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3334, "upload_time": "2014-12-22T22:32:01", "url": "https://files.pythonhosted.org/packages/3b/e5/bb3f98a4d25a3d0b7e2a95a8a99485552f2587b5f918b1db1a97dcef8621/simian-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "beef0329d5aaf41829be7079a22a8e1d", "sha256": "0afbd735421f6f888ee7269404062a387a6b8784282471260e9e217aad358c59" }, "downloads": -1, "filename": "simian-1.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "beef0329d5aaf41829be7079a22a8e1d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3692, "upload_time": "2014-12-23T17:40:50", "url": "https://files.pythonhosted.org/packages/4b/64/55d1d55557269c99ed1672bee32731beb6b05a05ea349adc9ba4b4d3a9fb/simian-1.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "239291913098762d7ca515251ed3a4e5", "sha256": "75cb3d3416c7eb27da74ae057aa7372b52d3ac7372b4ef6ae75af4277b8cdd1b" }, "downloads": -1, "filename": "simian-1.0.6.tar.gz", "has_sig": false, "md5_digest": "239291913098762d7ca515251ed3a4e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3450, "upload_time": "2014-12-23T17:40:47", "url": "https://files.pythonhosted.org/packages/ec/9c/980a4c68254f59d5cff6edaf854e7b15958546346e9391667392ef80b191/simian-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "b564df6d2a5bd0b15f8eb5cb1bf8b064", "sha256": "47dda588704ae96f89a0b7ecc581f41f6c8c89ce7a98a1d337ff66724a8166fe" }, "downloads": -1, "filename": "simian-1.0.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b564df6d2a5bd0b15f8eb5cb1bf8b064", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3725, "upload_time": "2014-12-23T19:29:12", "url": "https://files.pythonhosted.org/packages/42/0b/1a3ee5d52ec246fcc00877df09e82196e2c63c40b035cfc382e08bab4a5f/simian-1.0.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c0ec34873b90e4aff5cca7749f7c4ce9", "sha256": "be9427eeff20ad015ab870356feed07518b110bba3f97d0d8899636e5d66158b" }, "downloads": -1, "filename": "simian-1.0.7.tar.gz", "has_sig": false, "md5_digest": "c0ec34873b90e4aff5cca7749f7c4ce9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3466, "upload_time": "2014-12-23T19:29:09", "url": "https://files.pythonhosted.org/packages/a3/4e/509b6b59b77dfd7a6cca4a6bb8cf7ae59a5d430355eb359067b0806059db/simian-1.0.7.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "41f8c56e9c6570186bcf77ae442bd093", "sha256": "fd67335019b90078a5d89e0af20963bceea3b4ecd4365c79e8a2ce090ff8fb8f" }, "downloads": -1, "filename": "simian-2.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "41f8c56e9c6570186bcf77ae442bd093", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3640, "upload_time": "2014-12-24T03:58:54", "url": "https://files.pythonhosted.org/packages/1c/eb/f982a28107f9c4ae05f49e851284780adc0c124551a0ec7859341f15db7f/simian-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "28dc509c6990ac10b497d02fd24ea4ca", "sha256": "86ab477e4793b0b6a35b94f9a3a218173587d6ed7d76ccd5125ef52e9cbadcd8" }, "downloads": -1, "filename": "simian-2.0.0.tar.gz", "has_sig": false, "md5_digest": "28dc509c6990ac10b497d02fd24ea4ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3297, "upload_time": "2014-12-24T03:58:51", "url": "https://files.pythonhosted.org/packages/3e/cd/50af692bb724f41f91555bdf053acd825bc5b19261221fb9186567859d2d/simian-2.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "41f8c56e9c6570186bcf77ae442bd093", "sha256": "fd67335019b90078a5d89e0af20963bceea3b4ecd4365c79e8a2ce090ff8fb8f" }, "downloads": -1, "filename": "simian-2.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "41f8c56e9c6570186bcf77ae442bd093", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3640, "upload_time": "2014-12-24T03:58:54", "url": "https://files.pythonhosted.org/packages/1c/eb/f982a28107f9c4ae05f49e851284780adc0c124551a0ec7859341f15db7f/simian-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "28dc509c6990ac10b497d02fd24ea4ca", "sha256": "86ab477e4793b0b6a35b94f9a3a218173587d6ed7d76ccd5125ef52e9cbadcd8" }, "downloads": -1, "filename": "simian-2.0.0.tar.gz", "has_sig": false, "md5_digest": "28dc509c6990ac10b497d02fd24ea4ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3297, "upload_time": "2014-12-24T03:58:51", "url": "https://files.pythonhosted.org/packages/3e/cd/50af692bb724f41f91555bdf053acd825bc5b19261221fb9186567859d2d/simian-2.0.0.tar.gz" } ] }