{ "info": { "author": "Box", "author_email": "oss@box.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: OS Independent", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development" ], "description": "genty\n=====\n\n.. image:: http://opensource.box.com/badges/active.svg\n :target: http://opensource.box.com/badges\n\n.. image:: https://travis-ci.org/box/genty.png?branch=master\n :target: https://travis-ci.org/box/genty\n\n.. image:: https://img.shields.io/pypi/v/genty.svg\n :target: https://pypi.python.org/pypi/genty\n\n.. image:: https://img.shields.io/pypi/dm/genty.svg\n :target: https://pypi.python.org/pypi/genty\n\n\nAbout\n-----\n\nGenty, pronounced \"gen-tee\", stands for \"generate tests\". It promotes generative \ntesting, where a single test can execute over a variety of input. Genty makes\nthis a breeze.\n\nFor example, consider a file sample.py containing both the code under test and\nthe tests:\n\n.. code-block:: python\n\n from genty import genty, genty_repeat, genty_dataset\n from unittest import TestCase\n\n # Here's the class under test\n class MyClass(object):\n def add_one(self, x): \n return x + 1\n\n # Here's the test code\n @genty\n class MyClassTests(TestCase):\n @genty_dataset(\n (0, 1),\n (100000, 100001),\n )\n def test_add_one(self, value, expected_result):\n actual_result = MyClass().add_one(value)\n self.assertEqual(expected_result, actual_result)\n\n\nRunning the ``MyClassTests`` using the default unittest runner\n\n.. code-block:: console\n\n $ python -m unittest -v sample\n test_add_one(0, 1) (sample.MyClassTests) ... ok\n test_add_one(100000, 100001) (sample.MyClassTests) ... ok\n\n ----------------------------------------------------------------------\n Ran 2 tests in 0.000s\n\n OK\n\nInstead of having to write multiple independent tests for various test cases, \ncode can be refactored and parametrized using genty!\n\nIt produces readable tests.\nIt produces maintainable tests.\nIt produces expressive tests.\n\nAnother option is running the same test multiple times. This is useful in stress\ntests or when exercising code looking for race conditions. This particular test\n\n.. code-block:: python\n\n @genty_repeat(3)\n def test_adding_one_to_zero(self):\n self.assertEqual(1, MyClass().add_one(0))\n\n\nwould be run 3 times, producing output like\n\n.. code-block:: console\n\n $ python -m unittest -v sample\n test_adding_one() iteration_1 (sample.MyClassTests) ... ok\n test_adding_one() iteration_2 (sample.MyClassTests) ... ok\n test_adding_one() iteration_3 (sample.MyClassTests) ... ok\n\n ----------------------------------------------------------------------\n Ran 3 tests in 0.001s\n\n OK\n\nThe 2 techniques can be combined:\n\n.. code-block:: python\n\n @genty_repeat(2)\n @genty_dataset(\n (0, 1),\n (100000, 100001),\n )\n def test_add_one(self, value, expected_result):\n actual_result = MyClass().add_one(value)\n self.assertEqual(expected_result, actual_result)\n\n\nThere are more options to explore including naming your datasets and ``genty_args``.\n\n.. code-block:: python\n\n @genty_dataset(\n default_case=(0, 1),\n limit_case=(999, 1000),\n error_case=genty_args(-1, -1, is_something=False),\n )\n def test_complex(self, value1, value2, optional_value=None, is_something=True):\n ...\n\n\nwould run 3 tests, producing output like\n\n.. code-block:: console\n\n $ python -m unittest -v sample\n test_complex(default_case) (sample.MyClassTests) ... ok\n test_complex(limit_case) (sample.MyClassTests) ... ok\n test_complex(error_case) (sample.MyClassTests) ... ok\n\n ----------------------------------------------------------------------\n Ran 3 tests in 0.003s\n\n OK\n\n\nThe ``@genty_datasets`` can be chained together. This is useful, for example, if there are semantically different datasets\nso keeping them separate would help expressiveness.\n\n\n.. code-block:: python\n\n\t@genty_dataset(10, 100)\n\t@genty_dataset('first', 'second')\n\tdef test_composing(self, parameter_value):\n\t\t...\n\n\nwould run 4 tests, producing output like\n\n.. code-block:: console\n\n $ python -m unittest -v sample\n test_composing(10) (sample.MyClassTests) ... ok\n test_composing(100) (sample.MyClassTests) ... ok\n test_composing(u'first') (sample.MyClassTests) ... ok\n test_composing(u'second') (sample.MyClassTests) ... ok\n\n ----------------------------------------------------------------------\n Ran 4 tests in 0.000s\n\n OK\n\n\nSometimes the parameters to a test can't be determined at module load time. For example,\nsome test might be based on results from some http request. And first the test needs to\nauthenticate, etc. This is supported using the ``@genty_dataprovider`` decorator like so:\n\n\n.. code-block:: python\n\n def setUp(self):\n super(MyClassTests, self).setUp()\n\n # http authentication happens\n # And imagine that _some_function is actually some http request\n self._some_function = lambda x, y: ((x + y), (x - y), (x * y))\n\n @genty_dataset((1000, 100), (100, 1))\n def calculate(self, x_val, y_val):\n # when this is called... we've been authenticated\n return self._some_function(x_val, y_val)\n\n @genty_dataprovider(calculate)\n def test_heavy(self, data1, data2, data3):\n ...\n\n\nwould run 4 tests, producing output like\n\n.. code-block:: console\n\n\n\t$ python -m unittest -v sample\n\ttest_heavy_calculate(100, 1) (sample.MyClassTests) ... ok\n\ttest_heavy_calculate(1000, 100) (sample.MyClassTests) ... ok\n\n\t----------------------------------------------------------------------\n\tRan 2 tests in 0.000s\n\n\tOK\n\nNotice here how the name of the helper (``calculate``) is added to the names of the 2\nexecuted test cases.\n\nLike ``@genty_dataset``, ``@genty_dataprovider`` can be chained together.\n\nEnjoy!\n\nDeferred Parameterization\n-------------------------\n\nParametrized tests where the final parameters are not determined until test\nexecution time. It looks like so:\n\n.. code-block:: python\n\n @genty_dataset((1000, 100), (100, 1))\n def calculate(self, x_val, y_val):\n # when this is called... we've been authenticated, perhaps in\n # some Test.setUp() method.\n\n # Let's imagine that _some_function requires that authentication.\n # And it returns a 3-tuple, matching that signature of\n # of the test(s) decorated with this 'calculate' method.\n return self._some_function(x_val, y_val)\n\n @genty_dataprovider(calculate)\n def test_heavy(self, data1, data2, data3):\n ...\n\nThe ``calculate()`` method is called 2 times based on the ``@genty_dataset``\ndecorator, and each of it's return values define the final parameters that will\nbe given to the method ``test_heavy(...)``.\n\nInstallation\n------------\n\nTo install, simply:\n\n.. code-block:: console\n\n pip install genty\n\n\nContributing\n------------\n\nSee `CONTRIBUTING.rst `_.\n\n\nSetup\n~~~~~\n\nCreate a virtual environment and install packages -\n\n.. code-block:: console\n\n mkvirtualenv genty\n pip install -r requirements-dev.txt\n\n\nTesting\n~~~~~~~\n\nRun all tests using -\n\n.. code-block:: console\n\n tox\n\nThe tox tests include code style checks via pep8 and pylint.\n\nThe tox tests are configured to run on Python 2.6, 2.7, 3.3, 3.4, 3.5, and\nPyPy 2.6.\n\n\nCopyright and License\n---------------------\n\n::\n\n Copyright 2015 Box, Inc. All rights reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file 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": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/box/genty", "keywords": "genty,tests,generative,unittest", "license": "Apache Software License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0", "maintainer": "", "maintainer_email": "", "name": "genty", "package_url": "https://pypi.org/project/genty/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/genty/", "project_urls": { "Homepage": "https://github.com/box/genty" }, "release_url": "https://pypi.org/project/genty/1.3.2/", "requires_dist": [ "six", "ordereddict; python_version==\"2.6\"" ], "requires_python": "", "summary": "Allows you to run a test with multiple data sets", "version": "1.3.2" }, "last_serial": 1972866, "releases": { "0.1.0": [], "0.2.0": [ { "comment_text": "", "digests": { "md5": "ba3dde21050913c1ac97e28a199df037", "sha256": "3c6c93a88746fc59bba3b1ef61ca38741903950290a12ca76fb4c08fa596c51e" }, "downloads": -1, "filename": "genty-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ba3dde21050913c1ac97e28a199df037", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15047, "upload_time": "2014-04-05T10:26:44", "url": "https://files.pythonhosted.org/packages/29/54/c65bbe0a242c907b8b653bc49924fa3ba31e02eba6f3aa7dde8c44b541c2/genty-0.2.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "d2d9b559407788ed748c70fd293d51b5", "sha256": "9d4eaf5d0142e6596f0dd1d5fdbf9e28ffa8dfd59dd19f078d1178c3c78e952b" }, "downloads": -1, "filename": "genty-0.2.0.zip", "has_sig": false, "md5_digest": "d2d9b559407788ed748c70fd293d51b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29979, "upload_time": "2014-04-05T10:26:47", "url": "https://files.pythonhosted.org/packages/db/b4/f0c55711022113ee8f6ea98c3698064776a54a2522de8369f39b23894181/genty-0.2.0.zip" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "5f49586b312a33287491e9d5b0338be6", "sha256": "36a89bb7ba32ae013f698320e301813d423342a5ff2fa45fa24d2f09ec90af75" }, "downloads": -1, "filename": "genty-0.3.1.tar.gz", "has_sig": false, "md5_digest": "5f49586b312a33287491e9d5b0338be6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15981, "upload_time": "2014-08-29T22:44:09", "url": "https://files.pythonhosted.org/packages/ba/d6/f99a9784924e1e104b590704d5a34d4c0a0b2755465498ac536c006532d4/genty-0.3.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "8d9593db418d8ce4d6cbd33f8f414f70", "sha256": "f0c9d44521a3f1ecfa81bee22dcf849e21595cc2204bb334aa96d72b847d7d1a" }, "downloads": -1, "filename": "genty-1.0.0.tar.gz", "has_sig": false, "md5_digest": "8d9593db418d8ce4d6cbd33f8f414f70", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15705, "upload_time": "2014-09-01T01:34:25", "url": "https://files.pythonhosted.org/packages/e3/dd/f0647667cf80e1cced58c73609040af89cdb3d04da0a93128544b203dc1b/genty-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "2ee8cf6e552ceb2ba02fdaa249dd3d95", "sha256": "9181a6a71b9791ecca55adaa07e9952dbf1bd4338fcdc529f1ab8676e4d5d104" }, "downloads": -1, "filename": "genty-1.1.0.tar.gz", "has_sig": false, "md5_digest": "2ee8cf6e552ceb2ba02fdaa249dd3d95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18081, "upload_time": "2014-09-05T17:29:54", "url": "https://files.pythonhosted.org/packages/22/d8/f391c10fb2cc57bf8b71c9afa10193350c588baeb1d8e410eb294d48ab76/genty-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "08e3a51eee68b7eff480f6504b448314", "sha256": "c100c1f6ab6f9950e8c752b3e453678374a2e70df85265257a49c9a414327028" }, "downloads": -1, "filename": "genty-1.2.0.tar.gz", "has_sig": false, "md5_digest": "08e3a51eee68b7eff480f6504b448314", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21864, "upload_time": "2015-02-24T00:49:10", "url": "https://files.pythonhosted.org/packages/87/35/90ea7d2f2f683adf7f26966da67d785aaeb46bc8cadeeee0ef5398533d01/genty-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "2372dc3b42efe3dd334330a611e695b6", "sha256": "ba98da9fe33d51afe3bf35ec584851176a3ff9cefc82c4e081bad4a955f0c90f" }, "downloads": -1, "filename": "genty-1.2.1.tar.gz", "has_sig": false, "md5_digest": "2372dc3b42efe3dd334330a611e695b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21957, "upload_time": "2015-04-09T13:22:22", "url": "https://files.pythonhosted.org/packages/c3/98/75853f3aff9ff6706148c686ca326592a4af07f30e416dc1ebb95c49b371/genty-1.2.1.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "3770fa0b45a74acd7d8933d3953bcf83", "sha256": "fc9cee6100e10543dd512716e7b56c065e3c715700cd3309d0fa45683b005897" }, "downloads": -1, "filename": "genty-1.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "3770fa0b45a74acd7d8933d3953bcf83", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 22258, "upload_time": "2015-11-06T20:54:10", "url": "https://files.pythonhosted.org/packages/d5/7e/b04990e041d4a67c647a56f231d4fb6679878ee4a803cf6fad93b393b859/genty-1.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b57f5005501c56e7c04e9d0155b3b944", "sha256": "8c480cedf90070160584b6bec1a47a36d4d1c078b9ed24b7afdd21259671fdd3" }, "downloads": -1, "filename": "genty-1.3.0.tar.gz", "has_sig": false, "md5_digest": "b57f5005501c56e7c04e9d0155b3b944", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22751, "upload_time": "2015-11-06T20:54:02", "url": "https://files.pythonhosted.org/packages/ff/21/5e00685b3e63e6622ee74301d2a4032be0e1f9de40d7cd252cdd1db3b7b2/genty-1.3.0.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "8ca55ae91d523c3bf5f6c312deb59b4c", "sha256": "3ac027d1bb34bbda8634da625c44484528b62b05495792450564cdf55722f504" }, "downloads": -1, "filename": "genty-1.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8ca55ae91d523c3bf5f6c312deb59b4c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22346, "upload_time": "2016-02-18T19:52:24", "url": "https://files.pythonhosted.org/packages/df/2c/6cfccb715f1f15444a6327c101fd0a48975e3338a4d3a7bf22994da41d71/genty-1.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f5bbb4aa672269e93900631d90ec3952", "sha256": "6e7b7601b94762f9ce22f765343ab078683df9c620be24a5bb1b03ad5daeba89" }, "downloads": -1, "filename": "genty-1.3.1.tar.gz", "has_sig": false, "md5_digest": "f5bbb4aa672269e93900631d90ec3952", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23148, "upload_time": "2016-02-18T19:52:33", "url": "https://files.pythonhosted.org/packages/f3/f9/a9d5111fe3ab0beed2f0340c6d67deebd31d7f370dfc294df11810983bc1/genty-1.3.1.tar.gz" } ], "1.3.2": [ { "comment_text": "", "digests": { "md5": "7661238ddb67664abd499b7f47bf18b4", "sha256": "05d8fce895e0f1de7f0190cbfa0295fe33711ce09a81b70fdf4c49ed506e23d8" }, "downloads": -1, "filename": "genty-1.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7661238ddb67664abd499b7f47bf18b4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 19301, "upload_time": "2016-02-23T23:21:49", "url": "https://files.pythonhosted.org/packages/7f/b8/6f933799b3492f3632db7a64c389e62e189dd1f84cb659dc45f83a2c069d/genty-1.3.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "45141bfcd0b77ff8e52e5de2944ff157", "sha256": "2e3f5bfe2d3a757c0e2a48ac4716bca42d3b76d9cfc3401ef606635049c35dab" }, "downloads": -1, "filename": "genty-1.3.2.tar.gz", "has_sig": false, "md5_digest": "45141bfcd0b77ff8e52e5de2944ff157", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20818, "upload_time": "2016-02-23T23:22:46", "url": "https://files.pythonhosted.org/packages/c9/bc/eee096fe9ecf1041944f1327cf6a2030fb2c59acd66580b692eb8b540233/genty-1.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7661238ddb67664abd499b7f47bf18b4", "sha256": "05d8fce895e0f1de7f0190cbfa0295fe33711ce09a81b70fdf4c49ed506e23d8" }, "downloads": -1, "filename": "genty-1.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7661238ddb67664abd499b7f47bf18b4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 19301, "upload_time": "2016-02-23T23:21:49", "url": "https://files.pythonhosted.org/packages/7f/b8/6f933799b3492f3632db7a64c389e62e189dd1f84cb659dc45f83a2c069d/genty-1.3.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "45141bfcd0b77ff8e52e5de2944ff157", "sha256": "2e3f5bfe2d3a757c0e2a48ac4716bca42d3b76d9cfc3401ef606635049c35dab" }, "downloads": -1, "filename": "genty-1.3.2.tar.gz", "has_sig": false, "md5_digest": "45141bfcd0b77ff8e52e5de2944ff157", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20818, "upload_time": "2016-02-23T23:22:46", "url": "https://files.pythonhosted.org/packages/c9/bc/eee096fe9ecf1041944f1327cf6a2030fb2c59acd66580b692eb8b540233/genty-1.3.2.tar.gz" } ] }