{ "info": { "author": "Denver Coneybeare", "author_email": "denver@sleepydragon.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Testing" ], "description": "fakeable\nBy: Denver Coneybeare \nAug 12, 2013\n\nFakeable is a Python library that provides a facility for transparently\nreplacing objects with fake versions during unit testing. The main advantage\nof Fakeable is that from the point of view of the production code there is\nnothing that needs to be done except to declare a specific metaclass to opt-in\nto being faked. Then, during testing the tests specify to use a fake version\nof a specific class and then \"magically\" at runtime a fake version is used.\n\nFull documentation available at: https://fakeable.readthedocs.org\nSource code available at: https://github.com/sleepydragonsw/fakeable\n\nFor example, consider the class below, which simply reads the contents of a\ntext file and returns it:\n\n class FileReader(object):\n\n __metaclass__ = fakeable.Fakeable\n\n def read_file(self, path):\n with io.open(path, \"rt\", encoding=\"utf8\"):\n contents = f.read()\n return contents\n\nThen consider this class from production code that makes use of it:\n\n def file_contains(path, s):\n reader = FileReader()\n contents = reader.read_file(\"config.ini\")\n found = (s in contents)\n return found\n\nWhen the file_contains() method is invoked outside of unit tests everything\nwill work as expected: the real FileReader.read_file() method will be invoked.\nHowever, during unit tests, a fake version of the FileReader class can be used\ninstead:\n\n class FakeFileReader(object):\n def read_file(self, path):\n raise IOError(\"file not found\")\n\n class Test_FileReader(unittest.TestCase):\n def test_file_contains(self):\n fakeable.set_class(\"FileReader\", FakeFileReader)\n with self.assertRaises(IOError):\n file_contains(\"blah_blah\", \"hey ho\")\n\nWhen file_contains() is invoked after invoking fakeable.set_class() the call to\n\"reader = FileReader()\" will actually return an instance of FakeFileReader\ninstead of an instance of the *real* FileReader class.\n\nThis is achieved through the magic of metaclasses.\n\nSee the documentation in the \"doc\" folder for more details.", "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/sleepydragonsw/fakeable", "keywords": "fake,faking,mock,mocking", "license": "Apache License version 2.0", "maintainer": null, "maintainer_email": null, "name": "fakeable", "package_url": "https://pypi.org/project/fakeable/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/fakeable/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/sleepydragonsw/fakeable" }, "release_url": "https://pypi.org/project/fakeable/1.0.3/", "requires_dist": null, "requires_python": null, "summary": "enables seamless replacement of \"real\" objects with \"fake\" objects during unit testing", "version": "1.0.3" }, "last_serial": 851496, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "14263b8fb87e808eb192aab92179b83c", "sha256": "1f342aea6be93021fb78dff99eb1d7316796e6ad01a630c0dd69c4c0dcb2462b" }, "downloads": -1, "filename": "fakeable-1.0.0.tar.gz", "has_sig": false, "md5_digest": "14263b8fb87e808eb192aab92179b83c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9004, "upload_time": "2013-08-14T04:20:09", "url": "https://files.pythonhosted.org/packages/bf/4b/46c7934773639bdcefbd236338d7d85d073280c67e8cfe0ea427f50d49fe/fakeable-1.0.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "3609da842414dfe177e7a7ca18bc2389", "sha256": "1d40f62ecf539ee963992c7fefcfc71ce97bc2dc324005e8bf50b0aa9571c9ae" }, "downloads": -1, "filename": "fakeable-1.0.0.zip", "has_sig": false, "md5_digest": "3609da842414dfe177e7a7ca18bc2389", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11377, "upload_time": "2013-08-14T04:20:06", "url": "https://files.pythonhosted.org/packages/3f/95/f4cd854af4018688b9ccd4f397b03fe7390cdc9d2c93ba6b0f383394ab33/fakeable-1.0.0.zip" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c52b07b8472d9ed9be32e112d7228896", "sha256": "dab5b4c4c9cd592f803f5d171ab7fdd5baf7a8b135a329c3ed975887767ecba6" }, "downloads": -1, "filename": "fakeable-1.0.1.tar.gz", "has_sig": false, "md5_digest": "c52b07b8472d9ed9be32e112d7228896", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9038, "upload_time": "2013-08-14T04:24:02", "url": "https://files.pythonhosted.org/packages/45/54/b4ccd829edcb33bc373018d5a76eca90e859b5e02cce02ea7bd134122c91/fakeable-1.0.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "7c82a6e0edb97689cb8f9a82d72efd4f", "sha256": "88d9f6a9a91a0411dc9c6ff5537cb1a8a5b197c3c4ce629581ed9c3a117f0503" }, "downloads": -1, "filename": "fakeable-1.0.1.zip", "has_sig": false, "md5_digest": "7c82a6e0edb97689cb8f9a82d72efd4f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11471, "upload_time": "2013-08-14T04:24:00", "url": "https://files.pythonhosted.org/packages/b4/a6/fb1957c775f264a6617912d6ab5b46f7169874d6e67da60c0f0c5835a1b3/fakeable-1.0.1.zip" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "57e2427eb2db5e1589bfd5fd86ab27d7", "sha256": "4d5f7d30392877dca2b5293a97fc4c803c65f34018e52d8ac26d6d8e98007fec" }, "downloads": -1, "filename": "fakeable-1.0.2.tar.gz", "has_sig": false, "md5_digest": "57e2427eb2db5e1589bfd5fd86ab27d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20141, "upload_time": "2013-08-17T01:05:05", "url": "https://files.pythonhosted.org/packages/21/43/92bb5eb2638be53f30a5b4e11b6dbd3609fac9d892e6decd40b923c45757/fakeable-1.0.2.tar.gz" }, { "comment_text": "", "digests": { "md5": "816c0c7ed80b0583a0aa60a65965d44a", "sha256": "a7e1731b0db5170a53d74d270ec101738fd12fc815369582cf0c48a44ae685bb" }, "downloads": -1, "filename": "fakeable-1.0.2.zip", "has_sig": false, "md5_digest": "816c0c7ed80b0583a0aa60a65965d44a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25585, "upload_time": "2013-08-17T01:05:02", "url": "https://files.pythonhosted.org/packages/ab/3c/7084d11425094beba1eeaf8c11d85a670d7cf43ddaefdf9917b42d892d91/fakeable-1.0.2.zip" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "fb1111b6ce5669da757d559d3fec3e00", "sha256": "57378a5d0e6169f70e9fa65d6333a2861a887ceeb28f9374f53428c540034a39" }, "downloads": -1, "filename": "fakeable-1.0.3.tar.gz", "has_sig": false, "md5_digest": "fb1111b6ce5669da757d559d3fec3e00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23034, "upload_time": "2013-08-28T21:24:51", "url": "https://files.pythonhosted.org/packages/d9/70/1be16946f18dcf1ef767dbbe9e27107d70db00c14553f990d1e40acb6af2/fakeable-1.0.3.tar.gz" }, { "comment_text": "", "digests": { "md5": "46ea237a9e482d96238febf35abc3b74", "sha256": "14539ce1487af0a9422f4ae558967d89abb651e3f702529e23e66da295152d3d" }, "downloads": -1, "filename": "fakeable-1.0.3.zip", "has_sig": false, "md5_digest": "46ea237a9e482d96238febf35abc3b74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28214, "upload_time": "2013-08-28T21:24:48", "url": "https://files.pythonhosted.org/packages/d1/cf/5b3d8f2623e343418cafdbb4e159f1b49d562ee771248ecf31a3b22c8407/fakeable-1.0.3.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fb1111b6ce5669da757d559d3fec3e00", "sha256": "57378a5d0e6169f70e9fa65d6333a2861a887ceeb28f9374f53428c540034a39" }, "downloads": -1, "filename": "fakeable-1.0.3.tar.gz", "has_sig": false, "md5_digest": "fb1111b6ce5669da757d559d3fec3e00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23034, "upload_time": "2013-08-28T21:24:51", "url": "https://files.pythonhosted.org/packages/d9/70/1be16946f18dcf1ef767dbbe9e27107d70db00c14553f990d1e40acb6af2/fakeable-1.0.3.tar.gz" }, { "comment_text": "", "digests": { "md5": "46ea237a9e482d96238febf35abc3b74", "sha256": "14539ce1487af0a9422f4ae558967d89abb651e3f702529e23e66da295152d3d" }, "downloads": -1, "filename": "fakeable-1.0.3.zip", "has_sig": false, "md5_digest": "46ea237a9e482d96238febf35abc3b74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28214, "upload_time": "2013-08-28T21:24:48", "url": "https://files.pythonhosted.org/packages/d1/cf/5b3d8f2623e343418cafdbb4e159f1b49d562ee771248ecf31a3b22c8407/fakeable-1.0.3.zip" } ] }