{ "info": { "author": "Austin Stewart", "author_email": "austinfstewart@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Python Auto Mock\n================\n``auto_mock`` is a module for mocking during unit testing.\nIt automatically replaces all variables and functions external to the unit with default values to help developers exclude external state in their unit tests.\n\nInstallation\n------------\n``pip install python-auto-mock``\n\nUsage\n-----\n\nIn the example we will be making use of myclass.py\n\n``myclass.py``\n\n.. code:: python\n\n X = 1\n Y = 2\n Z = 3\n\n class MyClass():\n def addition_with_globals(self):\n print(X)\n print(Y)\n print(X + Y)\n return X + Y\n\nTo test this class we will write a test script.\n\n.. code:: python\n\n import auto_mock\n\n def test_my_class_addition():\n stubs = {\n 'X' : 36,\n 'Y' : 35,\n }\n\n with auto_mock.full_mock('myclass', 'MyClass.addition_with_globals', stubs) as addition_with_globals:\n if addition_with_globals() != 71:\n print(\"Addition is broken\")\n\n def main():\n test_my_class_addition()\n\n main()\n\nDone correctly this should print out\n\n::\n\n 36\n 35\n 71\n\n``full_mock`` takes 3 non optional arguments.\n\n1. The module name where the code is located.\n2. The specific function or method that is being tested.\n3. The dictionary of stubs/mocks that you would like to override the values with.\n\nThe stubs variable contains the names of the variables that are being mocked.\nIn this example we have ``X``, ``Y``, and ``Z`` as global variables.\nWe only use ``X`` and ``Y`` in this example, so they are the only variables that are in the stubs dictionary.\n\n``full_mock`` returns the function or method that you are trying to test with the external variables mocked.\nIf the variable is not within the stubs then it is mocked with a default object.\nInside the with block you can test that the function does what it is supposed to do.", "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/aaaustin10/Python-Auto-Mock", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "python-auto-mock", "package_url": "https://pypi.org/project/python-auto-mock/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-auto-mock/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/aaaustin10/Python-Auto-Mock" }, "release_url": "https://pypi.org/project/python-auto-mock/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "A module to easily mock code while testing.", "version": "0.1.1" }, "last_serial": 1978465, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d6e26b9fe1b842105de034632242a392", "sha256": "55ba17002e3dbffaa9019d3dc739526cc9cd359e14623c0121d89a00626168d8" }, "downloads": -1, "filename": "python_auto_mock-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d6e26b9fe1b842105de034632242a392", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 5356, "upload_time": "2015-06-01T16:38:59", "url": "https://files.pythonhosted.org/packages/04/65/31811428687130b94f2dd78c4d35e7cf6f3587fd947dd9afa89b1dbda26c/python_auto_mock-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3423c8b6385936deea87332f9f04cba2", "sha256": "e240aa89b89a4bee86abfcede66033b25db41f0ba59cfa6d9254c80752e3de1f" }, "downloads": -1, "filename": "python-auto-mock-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3423c8b6385936deea87332f9f04cba2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4307, "upload_time": "2015-06-01T16:38:43", "url": "https://files.pythonhosted.org/packages/cc/23/3251037338bafa4ef8d785c7e66f4ce19fd2ee0056a3265894bc1da00a51/python-auto-mock-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b52af7b577c47ec71f25e1565df219eb", "sha256": "5a37acfe229af2e480f5efb626cba6fa43821a4c85cbf68b593b001e56f56e61" }, "downloads": -1, "filename": "python_auto_mock-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b52af7b577c47ec71f25e1565df219eb", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 5424, "upload_time": "2016-02-26T17:46:38", "url": "https://files.pythonhosted.org/packages/f4/29/41d09cafbfac354e37cbb43c8b90908d669cae02675c9824ffbe741530a8/python_auto_mock-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "88ccc245e360ea7d72171943b50b36de", "sha256": "48b0be039aef5ab5821d397e5b58f611e6658fb713b25dff2dfd22eff628ba41" }, "downloads": -1, "filename": "python-auto-mock-0.1.1.tar.gz", "has_sig": false, "md5_digest": "88ccc245e360ea7d72171943b50b36de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4320, "upload_time": "2016-02-26T17:46:33", "url": "https://files.pythonhosted.org/packages/45/ab/ceaf1f9c5dd096ba8a6384ccb03103f36ab3332a99f5331c46c7864ceb28/python-auto-mock-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b52af7b577c47ec71f25e1565df219eb", "sha256": "5a37acfe229af2e480f5efb626cba6fa43821a4c85cbf68b593b001e56f56e61" }, "downloads": -1, "filename": "python_auto_mock-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b52af7b577c47ec71f25e1565df219eb", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 5424, "upload_time": "2016-02-26T17:46:38", "url": "https://files.pythonhosted.org/packages/f4/29/41d09cafbfac354e37cbb43c8b90908d669cae02675c9824ffbe741530a8/python_auto_mock-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "88ccc245e360ea7d72171943b50b36de", "sha256": "48b0be039aef5ab5821d397e5b58f611e6658fb713b25dff2dfd22eff628ba41" }, "downloads": -1, "filename": "python-auto-mock-0.1.1.tar.gz", "has_sig": false, "md5_digest": "88ccc245e360ea7d72171943b50b36de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4320, "upload_time": "2016-02-26T17:46:33", "url": "https://files.pythonhosted.org/packages/45/ab/ceaf1f9c5dd096ba8a6384ccb03103f36ab3332a99f5331c46c7864ceb28/python-auto-mock-0.1.1.tar.gz" } ] }