{ "info": { "author": "Gary Bernhardt", "author_email": "gary.bernhardt@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Testing" ], "description": "========\n DINGUSES\n ========\n \n A dingus is sort of like a mock object. The main difference is that you don't\n set up expectations ahead of time. You just run your code, using a dingus in\n place of another object or class, and it will record what happens to it. Then,\n once your code has been exercised, you can make assertions about what it did\n to the dingus.\n \n A new dingus is created from the Dingus class. You can give dinguses names,\n which helps with debugging your tests, especially when there are multiple\n dinguses in play.\n \n >>> from dingus import Dingus\n >>> d = Dingus('root')\n >>> d\n \n \n Accessing any attribute of a dingus will return a new dingus.\n \n >>> d.something\n \n \n There are a few exceptions for special dingus methods. We'll see some in a\n bit.\n \n A dingus can also be called like a function or method. It doesn't care how\n many arguments you give it or what those arguments are. Calls to a dingus will\n always return the same object, regardless of the arguments.\n \n >>> d()\n \n >>> d('argument')\n \n >>> d(55)\n \n \n ========================\n RECORDING AND ASSERTIONS\n ========================\n \n At any time we can get a list of calls that have been made to a dingus. Each\n entry in the call list contains:\n \n * the name of the method called (or \"()\" if the dingus itself was called)\n * The arguments, or () if none\n * The keyword argumnets, or {} if none\n * The value that was returned to the caller\n \n Here is a list of the calls we've made to d so far:\n \n >>> from pprint import pprint\n >>> pprint(d.calls)\n [('()', (), {}, ),\n ('()', ('argument',), {}, ),\n ('()', (55,), {}, )]\n \n You can filter calls by name, arguments, and keyword arguments:\n \n >>> pprint(d.calls('()', 55))\n [('()', (55,), {}, )]\n \n If you don't care about a particular argument's value, you can use the value\n DontCare when filtering:\n \n >>> from dingus import DontCare\n >>> pprint(d.calls('()', DontCare))\n [('()', ('argument',), {}, ),\n ('()', (55,), {}, )]\n \n Dinguses can do more than just have attributes accessed and be called. They\n support many Python operators. The goal is to allow, and record, any\n interaction:\n \n >>> d = Dingus('root')\n >>> (2 ** d.something)['hello']() / 100 * 'foo'\n \n \n (Hopefully your real-world dingus recordings won't look like this!)\n \n ========\n PATCHING\n ========\n \n Dingus provides a context manager for patching objects during tests. For\n example:\n \n >>> from dingus import patch\n >>> import urllib2\n >>> with patch('urllib2.urlopen'):\n ... print urllib2.urlopen.__class__\n \n >>> print urllib2.urlopen.__class__\n \n \n You can also use this as a decorator on your test methods:\n \n >>> @patch('urllib2.urlopen')\n ... def test_something(self):\n ... pass\n ...\n \n =========\n ISOLATION\n =========\n \n The opposite of patch is isolate. It patches everything except the named object:\n \n >>> from dingus import isolate\n >>> @isolate('urllib2.urlparse')\n ... def test_urlparse(self):\n ... pass\n ...\n \n When this test runs, everything in the urllib2 module except urlparse will be a\n dingus. Note that this may be slow to execute if the module contains many\n objects; performance patches are welcome. :)\n \n ===============\n DANGEROUS MAGIC\n ===============\n \n Dingus can also automatically replace a module's globals when running tests.\n This allows you to write fully isolated unit tests. See\n examples/urllib2/test\\_urllib2.py for an example. The author no longer\n recommends this feature, as it can encourage very brittle tests. You should\n feel the pain of manually mocking dependencies; the pain will tell you when a\n class collaborates with too many others.", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/garybernhardt/dingus", "keywords": "testing test mocking mock double stub fake record assert", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "dingus", "package_url": "https://pypi.org/project/dingus/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dingus/", "project_urls": { "Homepage": "https://github.com/garybernhardt/dingus" }, "release_url": "https://pypi.org/project/dingus/0.3.4/", "requires_dist": null, "requires_python": null, "summary": "A record-then-assert mocking library", "version": "0.3.4" }, "last_serial": 788971, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "301164559f95bc8e8478a9d610f17beb", "sha256": "736500f053f56b4c9b881883ce4ddfce70036677da19b869bae9abbb9fb50311" }, "downloads": -1, "filename": "dingus-0.1-py2.5.egg", "has_sig": false, "md5_digest": "301164559f95bc8e8478a9d610f17beb", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 6734, "upload_time": "2009-02-07T20:16:55", "url": "https://files.pythonhosted.org/packages/e5/37/e974bf293002d3a919ce90e397fa8d50b0dca73688ee75a8542340ca8336/dingus-0.1-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "209aba76651dbd37058d477b67f29541", "sha256": "b59a846793f6ecf42468a8db3585322c4f52fd0d7dff386ba5bf93c7b9fc01c9" }, "downloads": -1, "filename": "dingus-0.1.tar.gz", "has_sig": false, "md5_digest": "209aba76651dbd37058d477b67f29541", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9296, "upload_time": "2009-02-07T20:16:10", "url": "https://files.pythonhosted.org/packages/c0/d9/2feabd28d9c1718fd6c9ac82daed15a4c9809b64c5590305819c68782169/dingus-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "5c5a64e94023f41a0dc741f2828c491e", "sha256": "6a47b0c15fec599c10d7b3b7d4a5a9f911ee2ac71b6de1b9f6f794c81060d938" }, "downloads": -1, "filename": "dingus-0.2.tar.gz", "has_sig": false, "md5_digest": "5c5a64e94023f41a0dc741f2828c491e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4319, "upload_time": "2009-10-25T06:18:10", "url": "https://files.pythonhosted.org/packages/00/fc/df0dee886a387c82cc8501310d0530fc15bf5fdbf144678dc86faca4fc7b/dingus-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "0c032f54971eebbb93a07a6eca78aa73", "sha256": "22b04dfdbbcd46f5efd82964065d332b21bda05b3485d130f4e482798a950837" }, "downloads": -1, "filename": "dingus-0.3.tar.gz", "has_sig": false, "md5_digest": "0c032f54971eebbb93a07a6eca78aa73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5427, "upload_time": "2010-12-08T22:20:08", "url": "https://files.pythonhosted.org/packages/e7/c1/25a258620c2b0d2f58e6f9bd9d792ef3a0d1775e31154e376e5872d0f475/dingus-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "e5dba02620f37cd8e08a891504245fad", "sha256": "77c0f8acce79203b6f53c8ad06055fb77645763b206b23b043fe52af80a74a66" }, "downloads": -1, "filename": "dingus-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e5dba02620f37cd8e08a891504245fad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5772, "upload_time": "2010-12-16T22:14:23", "url": "https://files.pythonhosted.org/packages/8d/95/be2f9a693719c737f8606cff2ecb347662c0e44d450a4907c8c8e31f3fa2/dingus-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "9c7d1ca0adf51434a099c85c870334be", "sha256": "52df5ba4f9be18ace628fc241cc61345938fb9cb0154a8c79e13913421b3ca72" }, "downloads": -1, "filename": "dingus-0.3.2.tar.gz", "has_sig": false, "md5_digest": "9c7d1ca0adf51434a099c85c870334be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5917, "upload_time": "2011-02-24T20:36:16", "url": "https://files.pythonhosted.org/packages/1d/73/5c8b057438ac2e1c3d40d7be4f3838a0bca03e48db0ab21ad8d99decdbb3/dingus-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "0b6c47e511b076f2e034a07c0b08ca4d", "sha256": "e44b0ee01b5d50dd4f591d6767dbcda2db0d54187c15e3d6090636acbb9b3ecc" }, "downloads": -1, "filename": "dingus-0.3.3.tar.gz", "has_sig": false, "md5_digest": "0b6c47e511b076f2e034a07c0b08ca4d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6288, "upload_time": "2011-10-27T01:46:48", "url": "https://files.pythonhosted.org/packages/2e/20/b1fec8a32003a95bab89bf5a1995632570e5c03eb8429ac608edecd0ce19/dingus-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "5c26a789dcd054bf140985759865749e", "sha256": "eaacfcd17819eb9a0ee18c018be3a354a632a6e82b610d72f8a3bf33a1d7db35" }, "downloads": -1, "filename": "dingus-0.3.4.tar.gz", "has_sig": false, "md5_digest": "5c26a789dcd054bf140985759865749e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6202, "upload_time": "2012-03-14T19:31:35", "url": "https://files.pythonhosted.org/packages/0b/8f/c90b58edaef56b1a20f19652f1d6633acd03bb33d3c638963ac94eaf368e/dingus-0.3.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5c26a789dcd054bf140985759865749e", "sha256": "eaacfcd17819eb9a0ee18c018be3a354a632a6e82b610d72f8a3bf33a1d7db35" }, "downloads": -1, "filename": "dingus-0.3.4.tar.gz", "has_sig": false, "md5_digest": "5c26a789dcd054bf140985759865749e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6202, "upload_time": "2012-03-14T19:31:35", "url": "https://files.pythonhosted.org/packages/0b/8f/c90b58edaef56b1a20f19652f1d6633acd03bb33d3c638963ac94eaf368e/dingus-0.3.4.tar.gz" } ] }