{ "info": { "author": "Hellowlol", "author_email": "hellowlol1@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "# asserted\n[![Travis Status](https://travis-ci.org/Hellowlol/asserted.svg?branch=master)](https://travis-ci.org/Hellowlol/asserted)\n[![Cov](https://codecov.io/gh/hellowlol/asserted/branch/master/graph/badge.svg)](https://codecov.io/gh/hellowlol/asserted/branch/master)\n[![GitHub Releases](https://img.shields.io/github/tag/hellowlol/asserted.svg?label=github+release)](https://github.com/hellowlol/asserted/releases)\n[![PyPI version](https://badge.fury.io/py/asserted.svg)](https://pypi.python.org/pypi/asserted/)\n\nasserted is a simple tool that writes a pytest for the object your pass to it.\nThis is no way near perfect, you still have to handle imports, fixtures at but its handy if you need to check that all the properties are correct.\n\n#### CLI:\nasserted path/to/file\n```\nusage: asserted [-h] [-oa] [-wf] [-tp] [-sp SAVE_PATH] [-sm] [-st] [-q] fp\n\npositional arguments:\n fp The file you want to write test for.\n\noptional arguments:\n -h, --help show this help message and exit\n -oa, --only_attributes\n only attributes\n -wf, --write_full_tests\n write tests\n -tp, --test_prefix test prefix\n -sp SAVE_PATH, --save_path SAVE_PATH\n savepath\n -sm, --separate_methods\n Separate methods to there own test functions.\n -st, --sort_iterables\n Separate methods to there own test functions.\n -q Disable logging.\n```\n\n#### Code:\nSay you have a class like:\n````\nclass Ex(object):\n def __init__(self):\n self.data = 'data'\n self.att1 = 'att1'\n self.is_list = []\n self.is_dict = {}\n self.is_int = 1\n self.is_float = 0.5\n self.is_generator_expression = (i for i in range(2))\n self.is_datetime = datetime.datetime(1970, 1, 1)\n\n @property\n def props(self):\n \"\"\"Comment\"\"\"\n return 'props'\n\n def method(self):\n return 'method'\n\n async def async_metod(self):\n return 'async_metod'\n\n async def async_metod_two(self):\n return 'async_metod_two'\n\n @classmethod\n def a_classmethod(cls):\n return 'a_classmethod'\n\n @staticmethod\n def a_staticmethod():\n return 'a_staticmethod'\n\n @asyncio.coroutine\n def a_coro_with_return(self):\n return 'a_coro_with_return'\n\n def a_generator_function(self):\n for i in range(3):\n yield i\n\n def a_missing_arg(self, arg):\n return arg\n````\n\n````\nassert_write(asserted.example_class.Ex(), write_full_tests=True, separate_methods=True, sort_iterables=True)\n# Will create the code below.\n````\n\n````\ndef test_ex():\n ex = asserted.example_class.Ex()\n assert ex.att1 == \"att1\"\n assert ex.data == \"data\"\n assert str(ex.is_datetime.date()) == \"1970-01-01\"\n assert sorted(ex.is_dict.items()) == [('a', 'a'), ('b', 'b')]\n assert ex.is_false is False\n assert ex.is_float == 0.5\n assert sorted(list(ex.is_generator_expression)) == [0, 1]\n assert ex.is_int == 1\n assert sorted(ex.is_list) == [1, 2, 3, 4, 5]\n assert ex.is_true is True\n assert sorted(ex.is_tuple) == [1, 2, 3]\n assert ex.props == \"props\"\n\ndef test_ex_classmethod():\n ex = asserted.example_class.Ex()\n assert ex.a_classmethod() == \"a_classmethod\"\n\ndef test_ex_coro_with_return():\n ex = asserted.example_class.Ex()\n\n async def gogo():\n a_coro_with_return = await ex.a_coro_with_return()\n assert a_coro_with_return == \"a_coro_with_return\"\n asyncio.get_event_loop().run_until_complete(gogo())\n\ndef test_ex_generator_function():\n ex = asserted.example_class.Ex()\n assert sorted(list(ex.a_generator_function())) == [0, 1, 2]\n\ndef test_ex_a_staticmethod():\n ex = asserted.example_class.Ex()\n assert ex.a_staticmethod() == \"a_staticmethod\"\n\ndef test_ex_async_metod():\n ex = asserted.example_class.Ex()\n\n async def gogo():\n async_metod = await ex.async_metod()\n assert async_metod == \"async_metod\"\n asyncio.get_event_loop().run_until_complete(gogo())\n\ndef test_ex_async_metod_two():\n ex = asserted.example_class.Ex()\n\n async def gogo():\n async_metod_two = await ex.async_metod_two()\n assert async_metod_two == \"async_metod_two\"\n asyncio.get_event_loop().run_until_complete(gogo())\n\ndef test_ex_method():\n ex = asserted.example_class.Ex()\n assert ex.method() == \"method\"\n\ndef test_ex_missing_a_arg():\n ex = asserted.example_class.Ex()\n assert ex.missing_a_arg() == \"Missing_ARG\"\n\n````", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Hellowlol/asserted", "keywords": "pytest,helper,automate", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "asserted", "package_url": "https://pypi.org/project/asserted/", "platform": "", "project_url": "https://pypi.org/project/asserted/", "project_urls": { "Homepage": "https://github.com/Hellowlol/asserted" }, "release_url": "https://pypi.org/project/asserted/0.0.7/", "requires_dist": null, "requires_python": "~=3.5", "summary": "pytest assert writer", "version": "0.0.7" }, "last_serial": 3016028, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d4c9faeed774300bcf6438563f893926", "sha256": "c17576ce2b3aba73b7777c948de8d583c5dab621cc62856782f8fb091417bebf" }, "downloads": -1, "filename": "asserted-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d4c9faeed774300bcf6438563f893926", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8186, "upload_time": "2017-07-08T22:39:38", "url": "https://files.pythonhosted.org/packages/e7/1c/8ab6c31e2838aea18e3a2a8eb7c99d5541e5d5b01d00b1849584449cf05d/asserted-0.0.1.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "88567e473312d8d4fc9b1b2c5c139329", "sha256": "00071bda2df3b764b46c99a2284a6af931dc58e07c33a682b98a0a104b44470a" }, "downloads": -1, "filename": "asserted-0.0.3.tar.gz", "has_sig": false, "md5_digest": "88567e473312d8d4fc9b1b2c5c139329", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 10328, "upload_time": "2017-07-09T11:36:06", "url": "https://files.pythonhosted.org/packages/bc/b8/9b3b4be223a3ad326ce0ceac1463b7e56472c27f097fd52b52e82d31e928/asserted-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "d405a6d7ebb679d134fbc047162e5fe8", "sha256": "399a5d0792a5b4d3fde538ee5b0e13af94eba1f2111d550765debf39896620c4" }, "downloads": -1, "filename": "asserted-0.0.4.tar.gz", "has_sig": false, "md5_digest": "d405a6d7ebb679d134fbc047162e5fe8", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 9941, "upload_time": "2017-07-09T11:56:47", "url": "https://files.pythonhosted.org/packages/de/39/0b9d961a50d35dcda979c26c5fb9607e529446d3293f4e129918ab62bbb4/asserted-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "a5df01140bf8d3ee2e1113bb48e80995", "sha256": "bfe7919b3ec0d8fe9be4d9d1e9a79bcf5b172273425f9f88d9f61e1e26a5ef2e" }, "downloads": -1, "filename": "asserted-0.0.5.tar.gz", "has_sig": false, "md5_digest": "a5df01140bf8d3ee2e1113bb48e80995", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 10044, "upload_time": "2017-07-09T21:44:19", "url": "https://files.pythonhosted.org/packages/b1/3c/8689e6099e6586ca7e54d4a803d33f9cf1416c60b1c4af61331616dfa7a2/asserted-0.0.5.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "5d902b6beb1dfe0b08654575af2d99b7", "sha256": "c9f66a8f917a2eeedbc6157f3dfaababb1fc4ea2bfaea8e6935973dcf3e031d8" }, "downloads": -1, "filename": "asserted-0.0.7.tar.gz", "has_sig": false, "md5_digest": "5d902b6beb1dfe0b08654575af2d99b7", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 11377, "upload_time": "2017-07-11T22:49:08", "url": "https://files.pythonhosted.org/packages/4e/0d/746a73189ed8b5dfd457ca26be26ebf8131c90cdd3604e1235397e0559e7/asserted-0.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5d902b6beb1dfe0b08654575af2d99b7", "sha256": "c9f66a8f917a2eeedbc6157f3dfaababb1fc4ea2bfaea8e6935973dcf3e031d8" }, "downloads": -1, "filename": "asserted-0.0.7.tar.gz", "has_sig": false, "md5_digest": "5d902b6beb1dfe0b08654575af2d99b7", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 11377, "upload_time": "2017-07-11T22:49:08", "url": "https://files.pythonhosted.org/packages/4e/0d/746a73189ed8b5dfd457ca26be26ebf8131c90cdd3604e1235397e0559e7/asserted-0.0.7.tar.gz" } ] }