{ "info": { "author": "Justin Iso", "author_email": "justin+assertionchain@justiniso.com", "bugtrack_url": null, "classifiers": [], "description": "AssertionChain\n=============\n\n[![Build Status](https://travis-ci.org/justiniso/AssertionChain.svg)](https://travis-ci.org/justiniso/AssertionChain) [![Coverage Status](https://coveralls.io/repos/justiniso/AssertionChain/badge.svg?branch=master)](https://coveralls.io/r/justiniso/AssertionChain?branch=master)\n\nAn AssertionChain is a wrapper for a group of commands that must happen in sequence.\n\nInstallation:\n\n pip install assertionchain\n\nFeatures:\n\n- Control order of execution of a group of functions\n- Terminate execution of the rest of the chain if certain conditions are not met\n\nSimple example:\n\n AssertionChain()\\\n .do(lambda: 1 + 1, 'Add two numbers together') \\\n .expect(3, message='Step \"{step}\" did not result in expected value {expected}, value was: {actual}') \\\n .perform()\n\nThis is roughly equivalent to:\n\n val = 1 + 1\n assert val == 3\n\nThe above example is certainly more readable, so why use an AssertionChain at all? For starters, the chain\nencourages the user to provide line-by-line detail about each step being executed. So if you want to understand\nwhy the above assertion failed, you would have to construct a detailed error message indicating the actual and\nexpected value along with the step that produced the actual value. That's not particularly hard:\n\n expected = 3\n val = 1 + 1\n message = 'Adding 1 + 1 did not result in expected value {expected}, value was: {actual}'.format(\n expected=expected,\n actual=val\n )\n assert val == expected, message\n\nBut having to repeat this every time you run a command can become very, very tedious. AssertionChain provides this\nAPI for performing incremental checks on each operation being executed in the chain, reducing the overhead of having\nto type all of this out.\n\nIt is a simple utility for grouping related actions and ensuring each step succeeds. For instance, assume we have a\nsuite of functions that interact with files (get_contents, write_contents, delete_file). Their contract stipulates\nthat each function will return True, False, or a value depending on whether or not they were successful. We can use an\nAssertionChain to make sure each step was successful:\n\n filename = '/tmp/sd9x0c2'\n new_contents = 'myfile'\n\n # Write the file, retrieve the contents\n contents = AssertionChain()\\\n .do(lambda: get_contents(filename), 'Retrieve file contents').expect(False, operator='is not')\\\n .do(lambda: write_contents(filename, new_contents), 'Write file content').expect(True, operator='is')\\\n .do(lambda: write_contents(filename, ''), 'Write empty file content').expect(True, operator='is')\\\n .perform()\n\n # Delete the file\n AssertionChain().do(lambda: delete_file(filename), 'Delete file').expect(True, operator='is').perform()\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/justiniso/assertionchain/tarball/0.1.0", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/justiniso/assertionchain", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "assertionchain", "package_url": "https://pypi.org/project/assertionchain/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/assertionchain/", "project_urls": { "Download": "https://github.com/justiniso/assertionchain/tarball/0.1.0", "Homepage": "https://github.com/justiniso/assertionchain" }, "release_url": "https://pypi.org/project/assertionchain/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Utility for chaining commands and incrementally checking the results", "version": "0.1.1" }, "last_serial": 1492206, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "724bc9d37ef13bae0136c86527557d1e", "sha256": "b7b012cbaaeaa058837868a4e228f5cff5737ecfc2f6530ff777bc9a048b45fe" }, "downloads": -1, "filename": "assertionchain-0.1.0.tar.gz", "has_sig": false, "md5_digest": "724bc9d37ef13bae0136c86527557d1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 821, "upload_time": "2015-04-06T01:28:58", "url": "https://files.pythonhosted.org/packages/51/69/042ad5e93375448092110a31aa54f69a2bbfd38e2b50d7fec94838d3aa50/assertionchain-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4473fe687449299d4f78f32e0c4b8079", "sha256": "36240f9002be3d4530d12954ebbfd2877bc10c43dc13554825993fd9a168b57f" }, "downloads": -1, "filename": "assertionchain-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4473fe687449299d4f78f32e0c4b8079", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5428, "upload_time": "2015-04-06T02:44:55", "url": "https://files.pythonhosted.org/packages/7e/dd/9884184ddfd39bb5fb9382cb7e1a2f8dedd6863c25c13e9a9fdfdd342b73/assertionchain-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4473fe687449299d4f78f32e0c4b8079", "sha256": "36240f9002be3d4530d12954ebbfd2877bc10c43dc13554825993fd9a168b57f" }, "downloads": -1, "filename": "assertionchain-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4473fe687449299d4f78f32e0c4b8079", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5428, "upload_time": "2015-04-06T02:44:55", "url": "https://files.pythonhosted.org/packages/7e/dd/9884184ddfd39bb5fb9382cb7e1a2f8dedd6863c25c13e9a9fdfdd342b73/assertionchain-0.1.1.tar.gz" } ] }