parameterizedtestcaseParameterized tests for Python's unittest module | |
Download |
parameterizedtestcase Ranking & Summary
Advertisement
- License:
- MIT/X Consortium Lic...
- Price:
- FREE
- Publisher Name:
- Marc Abramowitz
- Publisher web site:
- http://search.cpan.org/~msabramo/
parameterizedtestcase Tags
parameterizedtestcase Description
parameterizedtestcase provides parameterized 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:from parameterizedtestcase import ParameterizedTestCaseclass MyTests(ParameterizedTestCase): @ParameterizedTestCase.parameterize(("input", "expected_output"), ) 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 teststest_eval_input_2+4_expected_output_6 (tests.MyTests) ... oktest_eval_input_3+5_expected_output_8 (tests.MyTests) ... oktest_eval_input_6*9_expected_output_54 (tests.MyTests) ... ok----------------------------------------------------------------------Ran 3 tests in 0.001sOKProduct's homepage
parameterizedtestcase Related Software