python_unittest_parameterized_test_case
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
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:
~/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
Metadata
Release files for parameterizedtestcase 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| parameterizedtestcase-0.1.0.tar.gz | 4.9 kB | Without provenance | Details for parameterizedtestcase-0.1.0.tar.gz |
Release files / parameterizedtestcase-0.1.0.tar.gz
| Download URL | parameterizedtestcase-0.1.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ccc1d15d7e7ef153619a6a9cd45b170268cf82c67fdd336794c75139aae127e
|
|
BLAKE2b-256 checksum How to use checksums |
99144b82711b0c6a377c1e63f44641d3f4c63ec1f3acc6cc5e2d37109fd711ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for parameterizedtestcase 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.