{ "info": { "author": "Kyle Marek-Spartz", "author_email": "kyle.marek.spartz@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7" ], "description": "Props\n=====\n\nProperty-based testing for Python \u00e0 la\n`QuickCheck `__.\n\n``for_all``\n-----------\n\n``for_all`` takes a list of generators (see below) and a property. It\nthen tests the property for arbitrary values of the generators.\n\nHere\u2019s an example testing the commutative and associative properties of\n``int``\\ s:\n\n.. code:: python\n\n for_all(int, int)(lambda a, b: a + b == b + a)\n for_all(int, int)(lambda a, b: a * b == b * a)\n for_all(int, int, int)(lambda a, b, c: c * (a + b) == a * c + b * c)\n\nProperties\n----------\n\nProperties are functions which take instances of generators and return\n``True`` if their condition is met:\n\n.. code:: python\n\n def prop_associative(a, b, c):\n return a + (b + c) == (a + b) + c\n\n for_all(int, int, int)(prop_associative)\n for_all(float, float, float)(prop_associative) # Warning: float isn't actually associative!\n\nProperties can also fail early by raising ``AssertionError``:\n\n.. code:: python\n\n def prop_list_append_pop(list, element):\n if element not in list:\n list.append(element)\n assert element in list\n list.pop()\n return element not in list\n return element in list\n\n for_all(list, int)(prop_list_append_pop)\n\nGenerators\n----------\n\n*Note:* These are not the same as Python generators. We should rename\nthem. Generaters? Blech.\n\nA generator is a specification of a set of possible Python objects. A\ngenerator is either:\n\n- One of the following built-in types:\n\n - ``None``, ``bool``, ``int``, ``float``, ``long``, ``complex``,\n ``str``, ``tuple``, ``set``, ``list``, or ``dict``\n\n- A class that implements the ``ArbitraryInterface``\n- Or constructed using the generator combinators.\n\nCombinators\n~~~~~~~~~~~\n\n- ``maybe_a``\n\n - Generates either an arbitrary value of the specified generator or\n ``None``.\n\n- ``maybe_an``\n\n - An alias for ``maybe_a``. Provided for syntactic convenience.\n\n- ``one_of``\n\n - Generates an arbitrary value of one of the specified generators.\n\n- ``tuple_of``\n\n - Generates a tuple by generating values for each of the specified\n generators.\n\n- ``set_of``\n\n - Generates a homogeneous set of the specified generator. You can\n generate non-homogeneous sets using ``set``.\n\n- ``list_of``\n\n - Generates a homogeneous list of the specified generator. You can\n generate non-homogeneous lists using ``list``.\n\n- ``dict_of``\n\n - Generates a homogeneous dict of the specified generators using\n kwargs. You can generate non-homogeneous dicts using ``dict``.\n\n``arbitrary``\n-------------\n\n``arbitrary`` takes a generator and returns a single instance of the\ngenerator.\n\nArbitraryInterface\n------------------\n\nWe provide a mixin with one classmethod, ``arbitrary``, which raises\n``NotImplementedError``. To implement generators for your own classes,\nplease inherit from ArbitraryInterface and provide an implementation for\n``arbitrary``.\n\nHere\u2019s an example implementation of a Binary Tree class:\n\n.. code:: python\n\n class BinaryTree(ArbitraryInterface):\n ...\n @classmethod\n def arbitrary(cls):\n return arbitrary(one_of(Leaf, Node))\n\n class Leaf(BinaryTree):\n ...\n @classmethod\n def arbitrary(cls):\n return cls(...) # an instance of Leaf.\n\n class Node(BinaryTree):\n ...\n @classmethod\n def arbitrary(cls):\n return cls(\n ...\n # This is equivalent:\n arbitrary(BinaryTree),\n # to this:\n BinaryTree.arbitrary()\n ) # an instance of Node with two subtrees.\n\nAbstractTestArbitraryInterface\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe also provide an ``AbstractTestArbitraryInterface`` with you can mixin\nto your test cases for each class that implements ``ArbitraryInterface``\nto ensure the ``arbitrary`` method is implemented:\n\n.. code:: python\n\n class TestBinaryTree(AbstractTestArbitraryInterface,\n TestCase):\n def setUp(self):\n self.cls = BinaryTree\n\nTo Do\n=====\n\n- all built in types: http://docs.python.org/2/library/stdtypes.html\n- ranges\n- import some faker generators for more semantic random values\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://www.github.com/zeckalpha/props", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "props", "package_url": "https://pypi.org/project/props/", "platform": "", "project_url": "https://pypi.org/project/props/", "project_urls": { "Homepage": "https://www.github.com/zeckalpha/props" }, "release_url": "https://pypi.org/project/props/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "QuickCheck for Python", "version": "0.0.3" }, "last_serial": 4111070, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "c665121b10fcd323b8da75f9a56e2b42", "sha256": "974b5089892a1adcc23b65f46baefb5343960a87d6d5b5d0a3359c1023642df2" }, "downloads": -1, "filename": "props-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c665121b10fcd323b8da75f9a56e2b42", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4533, "upload_time": "2014-02-14T04:59:07", "url": "https://files.pythonhosted.org/packages/2e/4c/4fa0601e021a70e97533c26e728b61cd8c033d889bd36595857a91420a20/props-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "95eb6d36019f1b9060f201ef52c01a85", "sha256": "4234f1ed5a2b11bdf031d665c71e04c63228ab207c66099a09f6ea103318f3f3" }, "downloads": -1, "filename": "props-0.0.2.tar.gz", "has_sig": false, "md5_digest": "95eb6d36019f1b9060f201ef52c01a85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4510, "upload_time": "2014-02-14T05:03:45", "url": "https://files.pythonhosted.org/packages/0f/74/a303cd8bc5b11ca9f485f9fa790d779989e2426fa372f36eae3aa03cd47e/props-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "89ec1fcb2c7c6c22cecc4c36588a1b73", "sha256": "95a2e560fcf3cd5186e182c0091ea99a76525a7c2a24e999d1175725c7220c17" }, "downloads": -1, "filename": "props-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "89ec1fcb2c7c6c22cecc4c36588a1b73", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4940, "upload_time": "2018-07-28T06:34:08", "url": "https://files.pythonhosted.org/packages/dd/5c/de8686a5ebe03e6ae0f1e6b208950b92e7f3a2067dd1e73fceedb70efb11/props-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eecb9049d41c3e2120b951c25a994f3a", "sha256": "98f4afddaefbfe7a22b205b2751221f62f44685eb7bc8c962353c3d848ce7981" }, "downloads": -1, "filename": "props-0.0.3.tar.gz", "has_sig": false, "md5_digest": "eecb9049d41c3e2120b951c25a994f3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4760, "upload_time": "2018-07-28T06:34:09", "url": "https://files.pythonhosted.org/packages/05/99/dc1801925f3c72e17a525347e1edf4ceb7e85f70f12d0d21528a8ccdbc4f/props-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "89ec1fcb2c7c6c22cecc4c36588a1b73", "sha256": "95a2e560fcf3cd5186e182c0091ea99a76525a7c2a24e999d1175725c7220c17" }, "downloads": -1, "filename": "props-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "89ec1fcb2c7c6c22cecc4c36588a1b73", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4940, "upload_time": "2018-07-28T06:34:08", "url": "https://files.pythonhosted.org/packages/dd/5c/de8686a5ebe03e6ae0f1e6b208950b92e7f3a2067dd1e73fceedb70efb11/props-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eecb9049d41c3e2120b951c25a994f3a", "sha256": "98f4afddaefbfe7a22b205b2751221f62f44685eb7bc8c962353c3d848ce7981" }, "downloads": -1, "filename": "props-0.0.3.tar.gz", "has_sig": false, "md5_digest": "eecb9049d41c3e2120b951c25a994f3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4760, "upload_time": "2018-07-28T06:34:09", "url": "https://files.pythonhosted.org/packages/05/99/dc1801925f3c72e17a525347e1edf4ceb7e85f70f12d0d21528a8ccdbc4f/props-0.0.3.tar.gz" } ] }