parameterizedtestcase


Nameparameterizedtestcase JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/msabramo/python_unittest_parameterized_test_case
SummaryParameterized tests for Python's unittest module
upload_time2014-01-31 21:25:53
maintainerNone
docs_urlNone
authorMarc Abramowitz
requires_pythonNone
licenseMIT
keywords unittest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            python_unittest_parameterized_test_case
=======================================

.. image:: https://secure.travis-ci.org/msabramo/python_unittest_parameterized_test_case.png?branch=master
   :target: http://travis-ci.org/msabramo/python_unittest_parameterized_test_case

Parameterized tests for Python's unittest module

This was inspired by the `parameterized tests
feature <http://pytest.org/latest/example/parametrize.html>`_ in
`py.test <http://pytest.org/>`_. I had been using py.test for the
particular test that motivated this, but my colleague had some
reservations about using py.test and all I really needed was the
parameterized tests so I whipped this up with a bit of metaclass
hackery.


Example usage
-------------

.. code-block:: python

    from parameterizedtestcase import ParameterizedTestCase

    class MyTests(ParameterizedTestCase):
        @ParameterizedTestCase.parameterize(
            ("input", "expected_output"),
            [
                ("2+4", 6),
                ("3+5", 8),
                ("6*9", 54),
            ]
        )
        def test_eval(self, input, expected_output):
            self.assertEqual(eval(input), expected_output)

Result of running this::

    ~/dev/git-repos/python_unittest_parameterized_test_case$ python -m unittest -v tests
    test_eval_input_2+4_expected_output_6 (tests.MyTests) ... ok
    test_eval_input_3+5_expected_output_8 (tests.MyTests) ... ok
    test_eval_input_6*9_expected_output_54 (tests.MyTests) ... ok

    ----------------------------------------------------------------------
    Ran 3 tests in 0.001s

    OK


Supported Python versions
-------------------------

- Python 2.5
- Python 2.6
- Python 2.7
- Python 3.1
- Python 3.2
- Python 3.3
- PyPy 1.9
- Jython 2.5

or says `tox <http://tox.testrun.org/>`_::

    ~/dev/git-repos/python_unittest_parameterized_test_case$ tox
    ...
      py25: commands succeeded
      py26: commands succeeded
      py27: commands succeeded
      py31: commands succeeded
      py32: commands succeeded
      py33: commands succeeded
      jython: commands succeeded
      pypy: commands succeeded
      congratulations :)

You also can check the `latest Travis CI results
<http://travis-ci.org/msabramo/python_unittest_parameterized_test_case>`_, but
Travis doesn't build all of the above platforms.


Issues
------

Send your bug reports and feature requests to https://github.com/msabramo/python_unittest_parameterized_test_case/issues
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/msabramo/python_unittest_parameterized_test_case",
    "name": "parameterizedtestcase",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "unittest",
    "author": "Marc Abramowitz",
    "author_email": "marc@marc-abramowitz.com",
    "download_url": "https://files.pythonhosted.org/packages/99/14/4b82711b0c6a377c1e63f44641d3f4c63ec1f3acc6cc5e2d37109fd711ca/parameterizedtestcase-0.1.0.tar.gz",
    "platform": "UNKNOWN",
    "description": "python_unittest_parameterized_test_case\n=======================================\n\n.. image:: https://secure.travis-ci.org/msabramo/python_unittest_parameterized_test_case.png?branch=master\n   :target: http://travis-ci.org/msabramo/python_unittest_parameterized_test_case\n\nParameterized tests for Python's unittest module\n\nThis was inspired by the `parameterized tests\nfeature <http://pytest.org/latest/example/parametrize.html>`_ in\n`py.test <http://pytest.org/>`_. I had been using py.test for the\nparticular test that motivated this, but my colleague had some\nreservations about using py.test and all I really needed was the\nparameterized tests so I whipped this up with a bit of metaclass\nhackery.\n\n\nExample usage\n-------------\n\n.. code-block:: python\n\n    from parameterizedtestcase import ParameterizedTestCase\n\n    class MyTests(ParameterizedTestCase):\n        @ParameterizedTestCase.parameterize(\n            (\"input\", \"expected_output\"),\n            [\n                (\"2+4\", 6),\n                (\"3+5\", 8),\n                (\"6*9\", 54),\n            ]\n        )\n        def test_eval(self, input, expected_output):\n            self.assertEqual(eval(input), expected_output)\n\nResult of running this::\n\n    ~/dev/git-repos/python_unittest_parameterized_test_case$ python -m unittest -v tests\n    test_eval_input_2+4_expected_output_6 (tests.MyTests) ... ok\n    test_eval_input_3+5_expected_output_8 (tests.MyTests) ... ok\n    test_eval_input_6*9_expected_output_54 (tests.MyTests) ... ok\n\n    ----------------------------------------------------------------------\n    Ran 3 tests in 0.001s\n\n    OK\n\n\nSupported Python versions\n-------------------------\n\n- Python 2.5\n- Python 2.6\n- Python 2.7\n- Python 3.1\n- Python 3.2\n- Python 3.3\n- PyPy 1.9\n- Jython 2.5\n\nor says `tox <http://tox.testrun.org/>`_::\n\n    ~/dev/git-repos/python_unittest_parameterized_test_case$ tox\n    ...\n      py25: commands succeeded\n      py26: commands succeeded\n      py27: commands succeeded\n      py31: commands succeeded\n      py32: commands succeeded\n      py33: commands succeeded\n      jython: commands succeeded\n      pypy: commands succeeded\n      congratulations :)\n\nYou also can check the `latest Travis CI results\n<http://travis-ci.org/msabramo/python_unittest_parameterized_test_case>`_, but\nTravis doesn't build all of the above platforms.\n\n\nIssues\n------\n\nSend your bug reports and feature requests to https://github.com/msabramo/python_unittest_parameterized_test_case/issues",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Parameterized tests for Python's unittest module",
    "version": "0.1.0",
    "split_keywords": [
        "unittest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9c627d9e85e1632e74bbe67ed8057416",
                "sha256": "4ccc1d15d7e7ef153619a6a9cd45b170268cf82c67fdd336794c75139aae127e"
            },
            "downloads": -1,
            "filename": "parameterizedtestcase-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9c627d9e85e1632e74bbe67ed8057416",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4885,
            "upload_time": "2014-01-31T21:25:53",
            "upload_time_iso_8601": "2014-01-31T21:25:53.727181Z",
            "url": "https://files.pythonhosted.org/packages/99/14/4b82711b0c6a377c1e63f44641d3f4c63ec1f3acc6cc5e2d37109fd711ca/parameterizedtestcase-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2014-01-31 21:25:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "msabramo",
    "github_project": "python_unittest_parameterized_test_case",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": false,
    "tox": true,
    "lcname": "parameterizedtestcase"
}
        
Elapsed time: 0.02008s