{ "info": { "author": "Ray Harris", "author_email": "ray@harris.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing", "Topic :: Utilities" ], "description": "insist\n ======\n \n An easy-to-use assertion library for python.\n \n \n Quick Start\n ===========\n \n Install insist\n --------------\n \n ```\n $ pip install insist\n ```\n \n or\n \n ```\n $ sudo pip install insist\n ```\n \n Create Insist object\n --------------------\n \n ```python\n from insist import Insist\n \n insist = Insist()\n \n # Raise RuntimeError instead of AssertionError\n insist_rt = Insist(RuntimeError)\n \n # Prefix all messages with \"OOPS : \"\n insist_prefix = Insist(message_prefix=\"OOPS\")\n \n # Show both custom and standard error messages\n # Can be combined with message_prefix\n insist_both = Insist(always_show_standard=True)\n ```\n \n Make assertions\n ---------------\n \n ```python\n insist.true(1 == 1) # Valid assertion\n \n insist(1 == 1) # Same as insist.true(expr)\n \n insist(1 == 2) # Raises AssertionError\n \n # Raises AssertionError with custom error message\n insist(1 == 2, \"Danger, Will Robinson\")\n \n # Raises AssertionError with custom and standard error message joined with \" : \"\n insist_both(1 == 2, \"Danger, Will Robinson\")\n ```\n \n Reference\n =========\n \n All tests\n ---------\n \n ```python\n from insist import Insist\n \n insist = Insist()\n \n insist(x) # x == True\n \n insist.true(x) # x == True\n \n insist.false(x) # x == False\n \n insist.always(custom) # Always raise an error\n \n insist.equal(x, y) # x == y\n \n insist.not_equal(x, y) # x != y\n \n insist.less(x, y) # x < y\n \n insist.less_equal(x, y) # x <= y\n \n insist.greater(x, y) # x > y\n \n insist.greater_equal(x, y) # x >= y\n \n insist.is_same(x, y) # x is y\n \n insist.is_not(x, y) # x is not y\n \n insist.is_in(x, y) # x in y\n \n insist.not_in(x, y) # x not in y\n \n insist.is_subclass(x, y) # issubclass(x, y)\n \n insist.is_not_subclass(x, y) # not issubclass(x, y)\n \n insist.isa(x, y) # isinstance(x, y)\n \n insist.is_not_a(x, y) # not isinstance(x, y)\n \n insist.is_string(x, y) # isinstance(x, str) for Py3\n # isinstance(x, (str, unicode)) for Py2\n \n insist.is_not_string(x, y) # not isinstance(x, str) for Py3\n # not isinstance(x, (str, unicode)) for Py2\n \n insist.keys(x, required, optional, extra, custom) # See examples below\n \n # Dict used for remaining examples\n x = { 'a' : 1, 'b' : 2, 'c' : 3 }\n \n # Require that x has listed keys with additional keys allowed.\n insist.keys(x, required=['a', 'b']) # OK\n insist.keys(x, required=['a', 'd']) # Raises error\n \n # Require that x has listed keys with additional keys not allowed.\n insist.keys(x, required=['a', 'b'], extra=False) # Raises error\n \n # Require that x has listed keys but no keys other than optional keys allowed.\n insist.keys(x, required=['a', 'b'], optional=['c']) # OK\n insist.keys(x, required=['a', 'b'], optional=['d']) # Raises error\n ```\n \n Chainable Tests\n ---------------\n \n The \"that\" method retains its value and uses it as the first value for the remaining methods in chain.\n This simplifies the testing of a single value against multiple criteria.\n \n ```python\n from insist import Insist\n \n insist = Insist()\n \n x = 3\n \n insist.that(x).isa(int).greater_equal(0).less(10) # OK if x is integer from 0 to 9\n \n # The result of the \"that\" method may be stored in a variable as well.\n \n say_x = insist.that(x)\n \n say_x.isa(int).greater_equal(0)\n \n say_x.less(len(message))\n \n \n # In addition to the methods listed above, a \"that chain\" has two additional methods.\n # The has and not_has methods are similar to is_in and not_in except that the\n # arguments are reversed.\n \n x = [ 1, 2, 3 ]\n \n say_x = insist.that(x)\n \n say_x.has(1).has(2) # OK\n say_x.has(1).not_has(2) # Raises error\n say_x.has(1).has(5) # Raises error\n \n x = { 'a' : 1, 'b' : 2, 'c' : 3 }\n \n say_x = insist.that(x)\n \n say_x.has('a').has('b') # OK\n say_x.has('a').has('d') # Raises error\n ```\n \n \n \n Copyright and License\n =====================\n \n Copyright 2014 Ray Harris\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this module except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.", "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/ray-harris-net/insist", "keywords": null, "license": "LICENSE", "maintainer": null, "maintainer_email": null, "name": "insist", "package_url": "https://pypi.org/project/insist/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/insist/", "project_urls": { "Homepage": "https://github.com/ray-harris-net/insist" }, "release_url": "https://pypi.org/project/insist/0.2/", "requires_dist": null, "requires_python": null, "summary": "An easy-to-use assertion library for Python", "version": "0.2" }, "last_serial": 1215296, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "810368afa87e7d09fe30bedd5693b2a3", "sha256": "15ed75477dd84511d81c09dc245747125a58ddee9094d7d0dc8047a459ac742d" }, "downloads": -1, "filename": "insist-0.1.tar.gz", "has_sig": false, "md5_digest": "810368afa87e7d09fe30bedd5693b2a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4634, "upload_time": "2014-09-04T05:39:24", "url": "https://files.pythonhosted.org/packages/3b/8b/35b25a2b2f5907709d7cd3c01c50bcd2e2340b7e9c709263df960b3e9a68/insist-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "de53b6aa0abd6db085ea6acb80ccf868", "sha256": "a11e81d16c79932fc4820c9c5085d9ec73b765a5497bdb91355c254d2777199a" }, "downloads": -1, "filename": "insist-0.2.tar.gz", "has_sig": false, "md5_digest": "de53b6aa0abd6db085ea6acb80ccf868", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5118, "upload_time": "2014-09-06T18:25:06", "url": "https://files.pythonhosted.org/packages/8b/7d/5b6f4a1e633535bbc79a76f576dbc735127999251ce999ef1be6c6812697/insist-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "de53b6aa0abd6db085ea6acb80ccf868", "sha256": "a11e81d16c79932fc4820c9c5085d9ec73b765a5497bdb91355c254d2777199a" }, "downloads": -1, "filename": "insist-0.2.tar.gz", "has_sig": false, "md5_digest": "de53b6aa0abd6db085ea6acb80ccf868", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5118, "upload_time": "2014-09-06T18:25:06", "url": "https://files.pythonhosted.org/packages/8b/7d/5b6f4a1e633535bbc79a76f576dbc735127999251ce999ef1be6c6812697/insist-0.2.tar.gz" } ] }