{ "info": { "author": "Mario Corchero", "author_email": "mariocj89@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing" ], "description": "|Build Status| |Coverage Status| |Code Health| |PyPI Version|\n\nSealed Mock\n===========\n\nWhitelist the attributes/methods of your mocks instead of just letting\nit create new mock objects.\n\n`sealedmock` allows to specify when you are done defining the mock, ensuring\nthat any unexpected call to the mock is cached.\n\nSample:\n\n.. code:: python\n\n from unittest.mock import Mock\n from sealedmock import seal\n m = Mock()\n m.method1.return_value.attr1.method2.return_value = 1\n seal(m) # No new attributes can be declared\n m.method1().attr1.method2()\n # 1\n m.method1().attr2\n # Exception: AttributeError mock.method1().attr2\n\nBig news! This is getting into Python3.7! See `this PR <(https://github.com/python/cpython/pull/1923/files)>`_.\n\nInstall\n=======\n\n``pip install sealedmock``\n\nUsage\n=====\n\nGiven you have a file like:\n\n.. code:: python\n\n import urllib2\n\n class SampleCodeClass(object):\n \"\"\"This is sample code\"\"\"\n def calling_urlopen(self):\n return urllib2.urlopen(\"http://chooserandom.com\")\n\n def calling_splithost(self):\n return urllib2.splithost(\"//host:port/path\")\n\nYou can write a test like:\n\n.. code:: python\n\n from unittest.mock import patch\n from sealedmock import seal\n @patch(\"tests.sample_code.urllib2\")\n def test_using_decorator(mock):\n sample = sample_code.SampleCodeClass()\n mock.urlopen.return_value = 2\n\n seal(mock) # No new attributes can be declared\n\n # calling urlopen succeeds as mock.urlopen has been defined\n sample.calling_urlopen()\n\n # This will fail as mock.splithost has not been defined\n sample.calling_splithost()\n\nIf you use an common Mock the second part will pass as it will create a\nmock for you and return it. With sealedmock you can choose when to stop\nthat behaviour.\n\nThis is recursive so you can write:\n\n.. code:: python\n\n @patch(\"sample_code.secret\")\n def test_recursive(mock):\n sample = sample_code.SampleCodeClass()\n mock.secret.call1.call2.call3.return_value = 1\n seal(mock) # No new attributes can be declared\n\n # If secret is not used as specified above it will fail\n # ex: if do_stuff also calls secret.call1.call9\n sample.do_stuff()\n\nIt also prevents typos on tests if used like this:\n\n.. code:: python\n\n @patch(\"sample_code.secret\")\n def test_recursive(mock):\n sample = sample_code.SampleCodeClass()\n\n sample.do_stuff()\n\n seal(mock)\n mock.asert_called_with(1)\n # Note the typo in asert (should be assert)\n # A sealed mock will rise, normal mock won't\n\n.. |Build Status| image:: https://travis-ci.org/mariocj89/sealedmock.svg?branch=master\n :target: https://travis-ci.org/mariocj89/sealedmock\n.. |Coverage Status| image:: https://coveralls.io/repos/github/mariocj89/sealedmock/badge.svg?branch=master\n :target: https://coveralls.io/github/mariocj89/sealedmock?branch=master\n.. |Code Health| image:: https://landscape.io/github/mariocj89/sealedmock/master/landscape.svg?style=flat\n :target: https://landscape.io/github/mariocj89/sealedmock/master\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/sealedmock.svg\n :target: https://pypi.python.org/pypi/sealedmock/\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Mariocj89/sealedmock", "keywords": "mock", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "sealedmock", "package_url": "https://pypi.org/project/sealedmock/", "platform": "", "project_url": "https://pypi.org/project/sealedmock/", "project_urls": { "Homepage": "https://github.com/Mariocj89/sealedmock" }, "release_url": "https://pypi.org/project/sealedmock/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "Mocks that whitelist its interface", "version": "1.0.1" }, "last_serial": 3237542, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "f005fa42deb2d11f50d39fd6de465420", "sha256": "c83b0183b99384e7b24337ef40dc719772723fdba95ec466d2a98148c61e2efc" }, "downloads": -1, "filename": "sealedmock-0.1.0.tar.gz", "has_sig": false, "md5_digest": "f005fa42deb2d11f50d39fd6de465420", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2339, "upload_time": "2016-12-17T15:56:51", "url": "https://files.pythonhosted.org/packages/52/8e/9f3fe4c16d9ec9cec25aeb6b5d9dec0cc7e823545f5f0b863be3c0677b10/sealedmock-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e8d96ed183956b18751094d57b2a6fa3", "sha256": "2284b556f227f5eab9022a876a1dd5fb8f6e3437b432841f509c5123661797de" }, "downloads": -1, "filename": "sealedmock-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e8d96ed183956b18751094d57b2a6fa3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3312, "upload_time": "2016-12-18T11:33:38", "url": "https://files.pythonhosted.org/packages/18/7c/81383a2348e732e578ec99e2f5570b3de03aaf780476b0666c7be6f1155b/sealedmock-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "ef54215d03e4d02b74950fc835880ccb", "sha256": "417376b5d1b2a6594fce8da6d258df4ef1ae6e37f62fab37de0f6bcd8e7a4768" }, "downloads": -1, "filename": "sealedmock-0.3.0.tar.gz", "has_sig": false, "md5_digest": "ef54215d03e4d02b74950fc835880ccb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3387, "upload_time": "2016-12-18T19:05:47", "url": "https://files.pythonhosted.org/packages/de/9e/4a5f109d00852983d8a0d29f662863446d2cd81d036828a649d7aa8daae7/sealedmock-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "8ceb61acccd4389a33f2b18019e29029", "sha256": "123c24ebbbac3caecc0c9749d626d39c6e4c58b0e990396e8764f91264f20875" }, "downloads": -1, "filename": "sealedmock-0.4.0-py2-none-any.whl", "has_sig": false, "md5_digest": "8ceb61acccd4389a33f2b18019e29029", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 3799, "upload_time": "2017-06-20T22:22:14", "url": "https://files.pythonhosted.org/packages/d6/44/0c3a6820d616f5a4192d33802189db25e1a417080373885e03320c6d8038/sealedmock-0.4.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "755d9a8831ee795ca1178b01f7127101", "sha256": "b6d028c9a6b789c01f6eece38bf98cf8b648bc80abb0325c7cca1f228c6095df" }, "downloads": -1, "filename": "sealedmock-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "755d9a8831ee795ca1178b01f7127101", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3799, "upload_time": "2017-06-20T22:22:15", "url": "https://files.pythonhosted.org/packages/bd/64/c785cfa29b386e8442812d80b64b46d170a448d0ca335b9d7db780e4881c/sealedmock-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e18af4432e84186955cb46430c918f7b", "sha256": "32acc00b5c8979e6fccba055a449ed091f1ba54aeebfd5d2c8f44e927b698611" }, "downloads": -1, "filename": "sealedmock-0.4.0.tar.gz", "has_sig": false, "md5_digest": "e18af4432e84186955cb46430c918f7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2485, "upload_time": "2017-06-20T22:22:16", "url": "https://files.pythonhosted.org/packages/06/8c/0a85b2f5d1d4809d5a15610d41a239aebf05e2466f99139a096c0e2e9208/sealedmock-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "ab35eed7039fb23d2b3ab8d362500745", "sha256": "3e150560cabcac128e5f6364130754634881cf58b1e348aaa8fb70418f119f6d" }, "downloads": -1, "filename": "sealedmock-0.4.1-py2-none-any.whl", "has_sig": false, "md5_digest": "ab35eed7039fb23d2b3ab8d362500745", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 3736, "upload_time": "2017-06-20T22:26:56", "url": "https://files.pythonhosted.org/packages/ea/75/c00327203ea05c25f4095313d8ab85827686e71d2c45f01bd857c12f6f0a/sealedmock-0.4.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "acba3ead273e2195051a50c3e0d52dcb", "sha256": "7b2a3906f1440b023e58d025920e5fa18b4a82520cf711027c7d80546c4874bb" }, "downloads": -1, "filename": "sealedmock-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "acba3ead273e2195051a50c3e0d52dcb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3736, "upload_time": "2017-06-20T22:26:58", "url": "https://files.pythonhosted.org/packages/f5/44/6f6114c4b7ec5671400693dea86f4eefdba0ac120f537b3c8326429bf134/sealedmock-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d3cf3e9027905f09ec2f3d2dcf9482de", "sha256": "6c281fb2e65c29287d8d32bd9e563ff3e1299131702034fe866bc77ab066bc99" }, "downloads": -1, "filename": "sealedmock-0.4.1.tar.gz", "has_sig": false, "md5_digest": "d3cf3e9027905f09ec2f3d2dcf9482de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3337, "upload_time": "2017-06-20T22:26:59", "url": "https://files.pythonhosted.org/packages/3d/f4/084b57a22aa78cd8399ae5407fb8657ab6a277670b973e03203d68cb4a33/sealedmock-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "2180b08204a306f6d21306c83afb14dd", "sha256": "1ba5fad9c6bfe61d4f3e51cebf151c09f21c2b37251a684272eabb8f9da76abb" }, "downloads": -1, "filename": "sealedmock-0.4.2-py2-none-any.whl", "has_sig": false, "md5_digest": "2180b08204a306f6d21306c83afb14dd", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 5885, "upload_time": "2017-06-20T22:29:41", "url": "https://files.pythonhosted.org/packages/b9/15/8ae6ce925f4b1d5a04aba050ea884263f2e0f8bdd76abb41ac69710e802d/sealedmock-0.4.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4eafad92d92e886425676b01689527ff", "sha256": "c098fa23f1afc2273706c0c2088160af00db2cfb598b45a7459a96e6c5929e55" }, "downloads": -1, "filename": "sealedmock-0.4.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4eafad92d92e886425676b01689527ff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5886, "upload_time": "2017-06-20T22:29:42", "url": "https://files.pythonhosted.org/packages/9e/47/65b6468e7b20e4106e10ce1e51b286d5fe6880121db24a53498814f00ed3/sealedmock-0.4.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cdf2a32cf371d8ab7cd140dd407ad5c7", "sha256": "961de6b7bdf10fd9063411f23b34f345dd6835d56031690c4355e149db3ce8de" }, "downloads": -1, "filename": "sealedmock-0.4.2.tar.gz", "has_sig": false, "md5_digest": "cdf2a32cf371d8ab7cd140dd407ad5c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3648, "upload_time": "2017-06-20T22:29:43", "url": "https://files.pythonhosted.org/packages/08/f9/c03a235928253163135d7c8d5f38d9a0af9da36450a56326acc151699bd2/sealedmock-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "1f761dae213142e269b43309fe29c399", "sha256": "c9e5d7dd399a7aac972e7db7b2acda33f94b01ff9572694a5b9a58db6938580f" }, "downloads": -1, "filename": "sealedmock-0.4.3-py2-none-any.whl", "has_sig": false, "md5_digest": "1f761dae213142e269b43309fe29c399", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 5884, "upload_time": "2017-06-20T22:35:47", "url": "https://files.pythonhosted.org/packages/70/e7/7088936321038efb7365ecfb70145057f5e99e6061f0fd047e886b707bbd/sealedmock-0.4.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8e0b1a5ac1af5e45aee78e6b5e157245", "sha256": "8cc33279168d90f8ac2e7be439181c7d13caa34e03f1e584aa5c0e27d30e3193" }, "downloads": -1, "filename": "sealedmock-0.4.3-py3-none-any.whl", "has_sig": false, "md5_digest": "8e0b1a5ac1af5e45aee78e6b5e157245", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5849, "upload_time": "2017-06-20T22:35:48", "url": "https://files.pythonhosted.org/packages/83/b6/07bdaa3fee51cbe23466edc435809f2e03e9ba5c4fa3cbb556e4948f05cd/sealedmock-0.4.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "08bece6cd91eb68e0c17684b2491911b", "sha256": "6ed21242729384fc990c63a503ad273e5ed55d2a99d37b9dea431afe245e1ad2" }, "downloads": -1, "filename": "sealedmock-0.4.3.tar.gz", "has_sig": false, "md5_digest": "08bece6cd91eb68e0c17684b2491911b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3662, "upload_time": "2017-06-20T22:35:49", "url": "https://files.pythonhosted.org/packages/71/c1/ba03b0d0876f6c3726fc023001dae86a4e442540030e5d2a66b3cfb21669/sealedmock-0.4.3.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "588ef81613d15746d160b8b9c0b11081", "sha256": "ac8c1e1f5aedd99d4da3723b977dde8a969d5120a66708914b11cc454e07d6e6" }, "downloads": -1, "filename": "sealedmock-1.0.0.tar.gz", "has_sig": false, "md5_digest": "588ef81613d15746d160b8b9c0b11081", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3707, "upload_time": "2017-10-09T21:32:48", "url": "https://files.pythonhosted.org/packages/ce/5d/8b3d0ab617c298062c6b3bc9a6d9cd626cddd0f8b1eb020004cad4fbb58b/sealedmock-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c3e4f493471bda716d829ca7f52f09c0", "sha256": "1e6459faa3de1d002fa7c43b493d1beccc1897c3926a8e882bee962463119717" }, "downloads": -1, "filename": "sealedmock-1.0.1.tar.gz", "has_sig": false, "md5_digest": "c3e4f493471bda716d829ca7f52f09c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3660, "upload_time": "2017-10-09T21:37:52", "url": "https://files.pythonhosted.org/packages/50/04/2670a1fe34c3847fe861645a22afae39845b62383b3a736cb44c43f40135/sealedmock-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c3e4f493471bda716d829ca7f52f09c0", "sha256": "1e6459faa3de1d002fa7c43b493d1beccc1897c3926a8e882bee962463119717" }, "downloads": -1, "filename": "sealedmock-1.0.1.tar.gz", "has_sig": false, "md5_digest": "c3e4f493471bda716d829ca7f52f09c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3660, "upload_time": "2017-10-09T21:37:52", "url": "https://files.pythonhosted.org/packages/50/04/2670a1fe34c3847fe861645a22afae39845b62383b3a736cb44c43f40135/sealedmock-1.0.1.tar.gz" } ] }