{"library":"parameterized","title":"Parameterized","description":"Parameterized is a Python library that provides parameterized testing capabilities for various test frameworks like unittest, pytest, and nose. It simplifies writing data-driven tests by allowing the same test logic to be run with multiple sets of input data, reducing duplication and improving test coverage. The current version is 0.9.0, released in March 2023.","status":"active","version":"0.9.0","language":"en","source_language":"en","source_url":"https://github.com/wolever/parameterized","tags":["testing","unittest","pytest","nose","data-driven testing","parameterization"],"install":[{"cmd":"pip install parameterized","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.7 or newer.","package":"python","optional":false}],"imports":[{"note":"A common typo is to omit the 'e' from 'parameterized', leading to an ImportError or AttributeError.","wrong":"from parametrized import parameterized","symbol":"parameterized","correct":"from parameterized import parameterized"},{"note":"Used for more explicit parameter definitions, especially with keyword arguments.","symbol":"param","correct":"from parameterized import param"},{"note":"Used to parameterize an entire test class.","symbol":"parameterized_class","correct":"from parameterized import parameterized_class"}],"quickstart":{"code":"import unittest\nfrom parameterized import parameterized, param\nimport math\n\nclass TestMath(unittest.TestCase):\n\n    @parameterized([\n        (2, 2, 4),\n        (2, 3, 8),\n        (1, 9, 1),\n        (0, 9, 0),\n    ])\n    def test_pow(self, base, exponent, expected):\n        self.assertEqual(math.pow(base, exponent), expected)\n\n    @parameterized.expand([\n        (\"negative\", -1.5, -2.0),\n        (\"integer\", 1, 1.0),\n        (\"large fraction\", 1.6, 1),\n    ])\n    def test_floor(self, name, input_val, expected):\n        self.assertEqual(math.floor(input_val), expected)\n\n    @parameterized_class(('a', 'b', 'expected_sum'), [\n        (1, 2, 3),\n        (5, 5, 10),\n    ])\n    class TestMathClass(unittest.TestCase):\n        def test_add(self):\n            self.assertEqual(self.a + self.b, self.expected_sum)\n\n# To run these tests, you would typically use:\n# unittest.main(argv=['first-arg-is-ignored'], exit=False)\n# or a test runner like pytest/nose.","lang":"python","description":"This quickstart demonstrates how to use `parameterized` with Python's built-in `unittest` framework. It shows examples for parameterizing individual test methods using `@parameterized` and `@parameterized.expand`, and how to parameterize an entire test class using `@parameterized_class`."},"warnings":[{"fix":"Upgrade to Python 3.7+ or pin `parameterized` to version 0.8.1 or earlier.","message":"As of version 0.9.0, `parameterized` has dropped support for Python 2.x, 3.5, and 3.6. If you require these Python versions, you must use an older version of `parameterized` (e.g., 0.8.1).","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Ensure `@mock.patch` is below `@parameterized` and mocked arguments are last in the function signature.","message":"When combining `@parameterized` (or `@parameterized.expand`) with `@mock.patch`, the `@mock.patch` decorator must be placed *below* the `@parameterized` decorator. Additionally, the arguments introduced by `mock.patch` should appear *last* in the test method's signature. Incorrect ordering can lead to unexpected behavior or errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For very large datasets, consider generating test data on-the-fly within the test method itself, or exploring alternative parameterization methods suitable for streaming data if available within your test framework.","message":"If you use an iterator or generator to supply parameters to `@parameterized` or `@parameterized.expand`, all items will be loaded into memory *before* the test run begins. This can be a significant memory concern for very large or infinite parameter sets.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always ensure you install `parameterized` (with the 'e') via `pip install parameterized`.","message":"A common pitfall is installing `parametrized` (missing the 'e') instead of `parameterized`. This will result in an `AttributeError: 'function' object has no attribute 'expand'` when trying to use `parameterized.expand`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Keep test cases modular and focused. Break down complex scenarios into smaller, manageable tests. Each test should validate a specific aspect of functionality.","message":"Overcomplicating parameterized test cases with excessive parameters or too many variations within a single test can lead to confusion, difficulty in maintenance, and unclear results. This defeats the purpose of parameterized testing.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}