{ "info": { "author": "Antti Kaihola", "author_email": "antti dot kaihola at eniram and finally fi for finland", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "Multi-dimensional parameterized testing with Pytest\n===================================================\n\n.. image:: https://travis-ci.org/akaihola/testdimensions.svg?branch=master\n :target: https://travis-ci.org/akaihola/testdimensions\n\nThere are multiple ways to write parameterized tests in Python. Unittest has\nsome support these days, Nose allows yielding test cases, Pytest has built-in\nparameterization support, and the excellent nose_parameterized_ package enhances\nthese capabilities in most test frameworks.\n\n``testdimensions`` provides a convenient way to write multi-dimensional test\nmatrices in some simple scenarios. If your function accepts multiple arguments\nand you want to test a cross product set of parameter combinations,\n``testdimensions`` is for you.\n\nSpecify your tests as a table whose:\n\n- Y axis labels are values for the third-last parameter\n- X axis labels are values for the second-last paremeter\n- cell values are the expected values (last parameter)\n- columns are separated by two spaces\n (make sure this is true on all rows)\n\n.. code:: python\n\n # test_math.py\n @pytest_mark_dimensions('base,exponent,expected', '''\n # y: base\n # x: exponent\n # cell: expected\n\n 2 3 9\n 0 0 0 0\n 1 1 1 1\n 2 4 8 512\n ''')\n def test_pow(base, exponent, expected):\n assert math.pow(base, exponent) == expected\n\n\n @pytest_mark_dimensions('input,function,expected', '''\n round math.floor math.ceil\n -1.5 -2.0 -2.0 -1.0\n 1.0 1.0 1.0 1.0\n 1.6 2.0 1.0 2.0\n ''')\n def test_round_floor_ceil(input, function, expected):\n assert function(input) == expected\n\nOutput::\n\n $ pytest -v\n =========================== test session starts ===============================\n platform linux -- Python 3.5.2, pytest-3.0.3, py-1.4.31, pluggy-0.4.0\n collected 18 items\n\n test_math.py::test_pow[0-2-0] PASSED\n test_math.py::test_pow[0-3-0] PASSED\n test_math.py::test_pow[0-9-0] PASSED\n test_math.py::test_pow[1-2-1] PASSED\n test_math.py::test_pow[1-3-1] PASSED\n test_math.py::test_pow[1-9-1] PASSED\n test_math.py::test_pow[2-2-4] PASSED\n test_math.py::test_pow[2-3-8] PASSED\n test_math.py::test_pow[2-9-512] PASSED\n test_math.py::test_round_floor_ceil[-1.5-function0--2.0] PASSED\n test_math.py::test_round_floor_ceil[-1.5-function1--2.0] PASSED\n test_math.py::test_round_floor_ceil[-1.5-function2--1.0] PASSED\n test_math.py::test_round_floor_ceil[1.0-function3-1.0] PASSED\n test_math.py::test_round_floor_ceil[1.0-function4-1.0] PASSED\n test_math.py::test_round_floor_ceil[1.0-function5-1.0] PASSED\n test_math.py::test_round_floor_ceil[1.6-function6-2.0] PASSED\n test_math.py::test_round_floor_ceil[1.6-function7-1.0] PASSED\n test_math.py::test_round_floor_ceil[1.6-function8-2.0] PASSED\n\n ============================ 18 passed in 0.03 seconds ========================\n\nInstallation\n------------\n\n::\n\n $ pip install testdimensions\n\n\nCompatibility\n-------------\n\n.. list-table::\n :header-rows: 1\n :stub-columns: 1\n\n * -\n - Py2.6\n - Py2.7\n - Py3.3\n - Py3.4\n - Py3.5\n - PyPy\n * - nose\n - no\n - yes\n - no\n - no\n - yes\n - no\n * - nose2\n - no\n - no\n - no\n - no\n - no\n - no\n * - py.test\n - not tested\n - yes\n - not tested\n - not tested\n - yes\n - not tested\n * - unittest\n - no\n - no\n - no\n - no\n - no\n - no\n * - unittest2\n - no\n - no\n - no\n - no\n - no\n - no\n\nDependencies\n------------\n\n- nose_parameterized_ for Nose support\n\n\nExhaustive Usage Examples\n--------------------------\n\nThe ``@pytest_mark_dimensions`` decorator is an extension of\n``@pytest.mark.parametrize`` and requires a comma-separated list of test\nparameters as its first argument. The second argument is a multi-line string\nwhich defines the actual tests. You can also inject values into the test\nglobals namespace using keyword arguments.\n\nTo create higher than two-dimensional tests, just define multiple tables\ninterspersed with values for the additional parameters.\n\n.. code:: python\n\n @pytest_mark_dimensions('a,b,expected', '''\n -10 0 9 million\n -9 -19 -9 0 999991\n 0 -10 0 9 million\n 10 0 10 19 1000010\n ''',\n million=1000000)\n def test_add(a, b, expected):\n assert a + b == expected\n\n\n @pytest_mark_dimensions('operation,a,b,expected', '''\n operation = operator.sub\n\n -10 0 9 million\n -9 1 -9 -18 -1000009\n 0 10 0 -9 -million\n 10 20 10 1 -999990\n\n operation = operator.add\n\n -10 0 9 million\n -9 -19 -9 0 999991\n 0 -10 0 9 million\n 10 0 10 19 1000010\n\n operation = operator.mul\n\n -10 0 9 million\n -9 90 0 -81 -9000000\n 0 0 0 0 0\n 10 -100 0 90 10000000\n\n ''',\n million=1000000)\n def test_arithmetic_operations(operation, a, b, expected):\n assert operation(a, b) == expected\n\nFor Nose support, you need to install nose_parameterized_ and use the\n``@nosedimensions`` decorator:\n\n.. code:: python\n\n @nosedimensions('a,b,expected', '''\n -10 0 9 million\n -9 -19 -9 0 999991\n 0 -10 0 9 million\n 10 0 10 19 1000010\n ''',\n million=1000000)\n def test_add(a, b, expected):\n assert a + b == expected\n\n\n @nosedimensions('operation,a,b,expected', '''\n operation = operator.sub\n\n -10 0 9 million\n -9 1 -9 -18 -1000009\n 0 10 0 -9 -million\n 10 20 10 1 -999990\n\n operation = operator.add\n\n -10 0 9 million\n -9 -19 -9 0 999991\n 0 -10 0 9 million\n 10 0 10 19 1000010\n\n operation = operator.mul\n\n -10 0 9 million\n -9 90 0 -81 -9000000\n 0 0 0 0 0\n 10 -100 0 90 10000000\n\n ''',\n million=1000000)\n def test_arithmetic_operations(operation, a, b, expected):\n assert operation(a, b) == expected\n\nNote that you still need to enumerate the test parameters just like with Pytest.\n\n.. _nose_parameterized: https://pypi.org/project/nose-parameterized/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/akaihola/testdimensions", "keywords": null, "license": "FreeBSD", "maintainer": null, "maintainer_email": null, "name": "testdimensions", "package_url": "https://pypi.org/project/testdimensions/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/testdimensions/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/akaihola/testdimensions" }, "release_url": "https://pypi.org/project/testdimensions/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "Multi-dimensional parameterized tests for Pytest and Nose", "version": "0.0.1" }, "last_serial": 2464004, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "a85a31b70dc0c07d4d3b86436b554a57", "sha256": "1f110d2150609c2cb7feda5b03fedec4f70b8eb58fc7684e6d3559f3d36982cb" }, "downloads": -1, "filename": "testdimensions-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a85a31b70dc0c07d4d3b86436b554a57", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4651, "upload_time": "2016-11-16T11:54:13", "url": "https://files.pythonhosted.org/packages/78/88/7bb8798a994f218e2408d6a4dbdfa8baa8cf2d7a5082e5c709a4eb3b5531/testdimensions-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a85a31b70dc0c07d4d3b86436b554a57", "sha256": "1f110d2150609c2cb7feda5b03fedec4f70b8eb58fc7684e6d3559f3d36982cb" }, "downloads": -1, "filename": "testdimensions-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a85a31b70dc0c07d4d3b86436b554a57", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4651, "upload_time": "2016-11-16T11:54:13", "url": "https://files.pythonhosted.org/packages/78/88/7bb8798a994f218e2408d6a4dbdfa8baa8cf2d7a5082e5c709a4eb3b5531/testdimensions-0.0.1.tar.gz" } ] }