{ "info": { "author": "satyavijay shelke", "author_email": "satyavls99@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7" ], "description": "####\n# simple_mock\n####\n \n************\n## Introduction\n************\n\nThe motivation behind this library is to provide easy way of mocking to python functions while doing the unittest.\\\nThis library is based on \"mock\" module in python \n \n \n************\n## Installation\n************\n\nInstall via [pip](http://www.pip-installer.org/):\n\n $ pip install simple_mock\n\nInstall from source:\n\n $ git clone https://github.com/satyavls/simple_mock.git\n $ cd simple_mock\n $ python setup.py install\n\n## Usage\n\n```python\n# example - mocking single function to return some value or exception\n\nimport unittest\nfrom simple_mock import SimpleMock\n\n# import of function that needs to be patch in test case file\nfrom add_module import add_num\n\n\nclass TestAddNum(unittest.TestCase):\n\n def setUp(self):\n # create simple mock object \n self.simple_mock = SimpleMock()\n\n def tearDown(self):\n self.simple_mock.clear_all_patch()\n\n def test_add_num(self):\n \"\"\"\n This is example where add_num function is patched to return the 45 value\n \"\"\"\n # patch the add_num function to return 45 value\n patched_add_func = self.simple_mock.patch_func(func='add_num', exptd_ret_val=45)\n self.assertEqual(add_num(2, 2), 45)\n\n def test_add_num_exception(self):\n \"\"\"\n This is exmaple where add_num function is patched to return exception\n \"\"\"\n # Patch the add_num function to return ValueError \n patched_add_func = self.simple_mock.patch_func(func='add_num', exptd_err=ValueError,\n err_msg=\"exception raise in add_num\")\n self.assertRaises(ValueError, add_num)\n\n\nif __name__ == '__main__':\n unittest.main()\n\n```\nRefer [here](https://github.com/satyavls/simple_mock/tree/master/examples) for more detailed examples \n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\nPlease make sure to update tests or examples are appropriate.\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/satyavls/simple_mock", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "simple-mock", "package_url": "https://pypi.org/project/simple-mock/", "platform": "", "project_url": "https://pypi.org/project/simple-mock/", "project_urls": { "Homepage": "https://github.com/satyavls/simple_mock" }, "release_url": "https://pypi.org/project/simple-mock/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "simple patching for python functions", "version": "0.0.1" }, "last_serial": 5358004, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "09be2d6663026ee07a328f62718fc308", "sha256": "7dd00870d3698e1852e9675023d8d276ea81006ad42b3abe86767751d46634d2" }, "downloads": -1, "filename": "simple_mock-0.0.1.tar.gz", "has_sig": false, "md5_digest": "09be2d6663026ee07a328f62718fc308", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2877, "upload_time": "2019-06-04T14:46:04", "url": "https://files.pythonhosted.org/packages/f0/9b/ed2931161a35e0bbf7a1fdd6642067b30b9eae23aa7eb5d3148494484777/simple_mock-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "09be2d6663026ee07a328f62718fc308", "sha256": "7dd00870d3698e1852e9675023d8d276ea81006ad42b3abe86767751d46634d2" }, "downloads": -1, "filename": "simple_mock-0.0.1.tar.gz", "has_sig": false, "md5_digest": "09be2d6663026ee07a328f62718fc308", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2877, "upload_time": "2019-06-04T14:46:04", "url": "https://files.pythonhosted.org/packages/f0/9b/ed2931161a35e0bbf7a1fdd6642067b30b9eae23aa7eb5d3148494484777/simple_mock-0.0.1.tar.gz" } ] }