Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msabramo/python_unittest_parameterized_test_case
Parameterized tests for Python's unittest module
https://github.com/msabramo/python_unittest_parameterized_test_case
Last synced: 28 days ago
JSON representation
Parameterized tests for Python's unittest module
- Host: GitHub
- URL: https://github.com/msabramo/python_unittest_parameterized_test_case
- Owner: msabramo
- License: mit
- Created: 2012-08-24T15:26:53.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2021-12-23T22:20:26.000Z (about 3 years ago)
- Last Synced: 2024-11-30T02:20:15.769Z (about 1 month ago)
- Language: Python
- Size: 22.5 KB
- Stars: 14
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
parameterizedtestcase
=====================.. 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_caseParameterized tests for Python's unittest module
This was inspired by the `parameterized tests
feature `_ in
`py.test `_. 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.001sOK
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.5or says `tox `_::
~/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
`_, 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