{ "info": { "author": "Luke Benstead", "author_email": "kazade@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "sleuth\n======\n\nA minimal Python mocking library\n\n# Why Sleuth?\n\nMost Python projects use mock, which became unittest.mock in Python 3. So why write Sleuth?\n\nFirstly, Sleuth has a different take on mocking than Mock does which can essentially be summarised as \"mock functions not objects\". Mocking functions is an explicit, readable and predictable thing to do and leads to clean test cases and\nloosely-coupled code.\n\nSecondly, Sleuth aims to have a simple and expressive API. With Mock sometimes it's difficult to tell what's going on\nand which arguments you need to pass to mock things as you need. Sleuth breaks mocking functions into a set of clearly\ndefined use cases:\n\n - watch: You want to see how a function is called, but not change its behaviour.\n - switch: You want to replace a function with another one for testing.\n - detonate: You want to throw an exception when the function is called.\n - fake: You want to replace the function with another one which returns a particular value when called.\n\n# Usage\n\nWatch calls with sleuth.watch\n\n with sleuth.watch(\"some.path.to.thing\") as mock:\n result = thing(1, a=2)\n self.assertTrue(mock.called)\n self.assertEqual(1, mock.call_count)\n self.assertEqual([((1,), {a:2})], mock.calls)\n self.assertEqual(result, mock.call_returns[0])\n\nReplace functions with sleuth.switch...\n\n with sleuth.switch(\"some.path.to.thing\", lambda x: 'something') as mock:\n thing(1, a=2)\n self.assertTrue(mock.called)\n self.assertTrue(['something'], mock.call_returns)\n\n\nCause functions to throw exceptions with sleuth.detonate:\n\n with sleuth.detonate(\"some.path.to.thing\", exception=ValueError):\n try:\n thing(1, a=2)\n except ValueError:\n pass\n\nOr...\n\n with sleuth.detonate(\"some.path.to.thing\", exception=ValueError(\"Some custom thingy\")):\n try:\n thing(1, a=2)\n except ValueError:\n pass\n\nReplace functions with a specific return value with sleuth.fake\n\n with sleuth.fake(\"some.path.to.thing\", return_value=1) as mock:\n thing(1, a=2)\n\n self.assertEqual([1], mock.call_returns)\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kazade/sleuth", "keywords": "python,mock,testing,test,unittest,monkeypatch,patch,stub", "license": "", "maintainer": "", "maintainer_email": "", "name": "sleuth-mock", "package_url": "https://pypi.org/project/sleuth-mock/", "platform": "", "project_url": "https://pypi.org/project/sleuth-mock/", "project_urls": { "Homepage": "https://github.com/kazade/sleuth" }, "release_url": "https://pypi.org/project/sleuth-mock/0.1/", "requires_dist": null, "requires_python": "", "summary": "A minimal Python mocking library", "version": "0.1" }, "last_serial": 4656009, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ea2c041870a2b723fbb6803f582adff1", "sha256": "e5c43c53645f3e00aba88ba73198efb2316bb1302f41f1784fb86e0438f5dd88" }, "downloads": -1, "filename": "sleuth_mock-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ea2c041870a2b723fbb6803f582adff1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4507, "upload_time": "2019-01-03T11:03:26", "url": "https://files.pythonhosted.org/packages/d5/f1/82e5ee2a9f78bde051d241fbfd992dae52564b42f8620109305d22a898c9/sleuth_mock-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5256ce0c17278ffc926fe1240229fcc6", "sha256": "86a825ffd230d8c6ccbce3167ab549dba100940b9be0fe9039d0617048ba7944" }, "downloads": -1, "filename": "sleuth-mock-0.1.tar.gz", "has_sig": false, "md5_digest": "5256ce0c17278ffc926fe1240229fcc6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3483, "upload_time": "2019-01-03T11:03:28", "url": "https://files.pythonhosted.org/packages/42/5b/7705f5e35a65aba8eafb518bc3cc6ff0453c3758e1f42c08a69caffeffbd/sleuth-mock-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ea2c041870a2b723fbb6803f582adff1", "sha256": "e5c43c53645f3e00aba88ba73198efb2316bb1302f41f1784fb86e0438f5dd88" }, "downloads": -1, "filename": "sleuth_mock-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ea2c041870a2b723fbb6803f582adff1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4507, "upload_time": "2019-01-03T11:03:26", "url": "https://files.pythonhosted.org/packages/d5/f1/82e5ee2a9f78bde051d241fbfd992dae52564b42f8620109305d22a898c9/sleuth_mock-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5256ce0c17278ffc926fe1240229fcc6", "sha256": "86a825ffd230d8c6ccbce3167ab549dba100940b9be0fe9039d0617048ba7944" }, "downloads": -1, "filename": "sleuth-mock-0.1.tar.gz", "has_sig": false, "md5_digest": "5256ce0c17278ffc926fe1240229fcc6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3483, "upload_time": "2019-01-03T11:03:28", "url": "https://files.pythonhosted.org/packages/42/5b/7705f5e35a65aba8eafb518bc3cc6ff0453c3758e1f42c08a69caffeffbd/sleuth-mock-0.1.tar.gz" } ] }