{ "info": { "author": "U.G. Wilson", "author_email": "ugwilson@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Testing", "Topic :: Software Development :: Testing :: Mocking", "Topic :: Software Development :: Testing :: Unit" ], "description": "# unittest_additions\n\n[![pypi-version]][pypi]\n\nHelpful extras built to make python unittesting easier.\n\n`pip install unittest-additions`\n\n## Features\n\n* Additional Asserts\n* Temporary Files\n* Runtime Timer\n* `mock_open` Line Iteration\n\n## Example Uses\n\nBelow are some example uses for some of the features.\n\n### Temporary Files\n\n```python\ndef test_using_temp_file(self):\n with TestFile(TEST_FILE, TEST_DATA) as tf:\n \t# File TEST_FILE now exists with TEST_DATA inside.\n tf.append(MORE_TEST_DATA)\n # File TEST_FILE now has TEST_DATA with MORE_TEST_DATA appended.\n\n # File TEST_FILE no longer exists.\n```\n\n### RunTimer\n\nA RunTimer is provied to help compare run times of code.\n\n```python\nwith RunTimer() as t:\n t0 = t.split()\n t1 = t.split()\n\nt2 = t.overall()\n```\n\n### mock_open Line Iteration\n\nWhen mocking a file using `mock_open`, \"code-under-test\" using line iteration (as in the example below) will not work as expected. (`do_something` will not be called.)\n\n```python\ndef my_function(fn):\n with open(fn, 'r') as f:\n for l in f:\n \t do_something(l)\n```\n\nTo enable line iteration you can use `add_line_iter_to_mock_open`.\n\n```python\n @patch('builtins.open', new_callable=mock_open, read_data='line 0\\nline 1\\n')\n def test_function(self, open_mock):\n\n add_line_iter_to_mock_open(open_mock)\n\n # Line iteration over the mock_open read_data will now work.\n```\n\n### Additional Asserts\n\nTo use the additional asserts, add the mixin to your `TestCase` class.\n\n```python\nclass MixedTestCase(TestCase, AdditionalAssertsMixin):\n def test_a_test:\n self.assertIsEmpty([])\n self.assertIsNotEmpty(('hello',))\n```\n\nThe new asserts are:\n\n| Method | Checks that ...\n|-------------------------|----------------\n| `assertIsEmpty(c)` | `len(c) == 0`\n| `assertIsNotEmpty(c)` | `len(c) > 0`\n\n[pypi-version]: https://img.shields.io/pypi/v/unittest-additions.svg\n[pypi]: https://pypi.org/project/unittest-additions/\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/c0yote/unittest-additions", "keywords": "unittest mock", "license": "", "maintainer": "", "maintainer_email": "", "name": "unittest-additions", "package_url": "https://pypi.org/project/unittest-additions/", "platform": "", "project_url": "https://pypi.org/project/unittest-additions/", "project_urls": { "Bug Reports": "https://github.com/c0yote/unittest-additions/issues", "Homepage": "https://github.com/c0yote/unittest-additions", "Source": "https://github.com/c0yote/unittest-additions" }, "release_url": "https://pypi.org/project/unittest-additions/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Additional features to extend python unittest and mock.", "version": "0.1.3" }, "last_serial": 4843645, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "a521edd5875113f665cc17f06a11fcfc", "sha256": "2cc1ded45cdcdc3eca6c0ab12526b6049f58dccb4a2a54af1283623da605eb6c" }, "downloads": -1, "filename": "unittest_additions-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a521edd5875113f665cc17f06a11fcfc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3686, "upload_time": "2019-01-24T06:21:14", "url": "https://files.pythonhosted.org/packages/15/94/e80573660f6f2234af44bccf24765e8f7c57e4f92854416c506a43a228f1/unittest_additions-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2cb2dd6d2814935d643755d428a0f52f", "sha256": "5094f4abd352d1092dd1dc51521e7a372a5585c6b5031b570e521a69f86e165e" }, "downloads": -1, "filename": "unittest_additions-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2cb2dd6d2814935d643755d428a0f52f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2687, "upload_time": "2019-01-24T06:21:15", "url": "https://files.pythonhosted.org/packages/7e/e5/4010391647206106e29822ba3b6b9854e179bf5b5dcc82123735e92ba906/unittest_additions-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "1dd5710c24d1c5893ba057f95c66976a", "sha256": "dbe6b8f87b22b96529707ba445b183a3a083a4107bb275663068b52ded4a0ec3" }, "downloads": -1, "filename": "unittest_additions-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "1dd5710c24d1c5893ba057f95c66976a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3865, "upload_time": "2019-02-20T04:35:50", "url": "https://files.pythonhosted.org/packages/0f/e3/14595ccd4f3cd02eebc23910ad047e673b632f44b51447f0be6c047e38ff/unittest_additions-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "89e01949a1e7f5874bdc4a8d6f7bbc47", "sha256": "b6a4d10b8bc76224ed6fa57dfd184e820023a49f1b80ae73fd40b238665b7b79" }, "downloads": -1, "filename": "unittest_additions-0.1.3.tar.gz", "has_sig": false, "md5_digest": "89e01949a1e7f5874bdc4a8d6f7bbc47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2889, "upload_time": "2019-02-20T04:35:51", "url": "https://files.pythonhosted.org/packages/3a/ad/acc7a697bda2eec31527ace75f34eb3d54b10e9af592a3fb6039a651430f/unittest_additions-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1dd5710c24d1c5893ba057f95c66976a", "sha256": "dbe6b8f87b22b96529707ba445b183a3a083a4107bb275663068b52ded4a0ec3" }, "downloads": -1, "filename": "unittest_additions-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "1dd5710c24d1c5893ba057f95c66976a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3865, "upload_time": "2019-02-20T04:35:50", "url": "https://files.pythonhosted.org/packages/0f/e3/14595ccd4f3cd02eebc23910ad047e673b632f44b51447f0be6c047e38ff/unittest_additions-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "89e01949a1e7f5874bdc4a8d6f7bbc47", "sha256": "b6a4d10b8bc76224ed6fa57dfd184e820023a49f1b80ae73fd40b238665b7b79" }, "downloads": -1, "filename": "unittest_additions-0.1.3.tar.gz", "has_sig": false, "md5_digest": "89e01949a1e7f5874bdc4a8d6f7bbc47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2889, "upload_time": "2019-02-20T04:35:51", "url": "https://files.pythonhosted.org/packages/3a/ad/acc7a697bda2eec31527ace75f34eb3d54b10e9af592a3fb6039a651430f/unittest_additions-0.1.3.tar.gz" } ] }