Parameterized tests for Python's unittest module
Project description
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 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for parameterizedtestcase-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e467b91135ce2babc1d3ae7c77e1357dabc7031d541e2396afc25ce87f70c35 |
|
MD5 | d848dd9778346e51cfa491775011e8bf |
|
BLAKE2b-256 | 988310d3942706be2eba2b9963dfb0eb5a137667d3342dca7577b7b913d73d81 |