{"id":22516,"library":"unittest-parametrize","title":"unittest-parametrize","description":"A library to parametrize tests within unittest TestCases using decorators. Current version 1.8.0, released 2024-11-15, with monthly or on-demand releases.","status":"active","version":"1.8.0","language":"python","source_language":"en","source_url":"https://github.com/adamchainz/unittest-parametrize","tags":["testing","unittest","parametrize","python"],"install":[{"cmd":"pip install unittest-parametrize","lang":"bash","label":"Stable"}],"dependencies":[],"imports":[{"note":"unittest_parametrize is a separate package, not part of stdlib unittest.","wrong":"from unittest.parametrize import parametrize","symbol":"parametrize","correct":"from unittest_parametrize import parametrize"},{"note":"Package name is unittest-parametrize but import uses underscores.","wrong":"from parametrize import parametrize","symbol":"parametrize","correct":"from unittest_parametrize import parametrize"}],"quickstart":{"code":"from unittest import TestCase\nfrom unittest_parametrize import parametrize\n\nclass MyTest(TestCase):\n    @parametrize(\n        ('a', 'b', 'expected'),\n        [\n            (1, 2, 3),\n            (4, 5, 9),\n        ],\n    )\n    def test_add(self, a, b, expected):\n        self.assertEqual(a + b, expected)","lang":"python","description":"Basic parametrization of a test method with multiple sets of arguments."},"warnings":[{"fix":"Use pytest.mark.parametrize if using pytest.","message":"unittest-parametrize only works with unittest.TestCase subclasses, not with pytest or other frameworks. Cannot be used with pytest fixtures.","severity":"gotcha","affected_versions":"all"},{"fix":"Place @parametrize directly above the method definition, with other decorators below it.","message":"The decorator must be applied before any other decorators that modify test methods (e.g., @mock.patch). Order matters: parametrize should be the outermost decorator.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.9+.","message":"Support for Python 3.8 has been dropped since version 1.6.0.","severity":"deprecated","affected_versions":">=1.6.0"},{"fix":"If you use ids as a list, it still works. Only breaking if you passed a callable that was previously ignored; now it is used to generate ids.","message":"In version 1.8.0, the 'ids' parameter changed from accepting a list of strings to also accepting a callable. Code that relied on the old exact list format may break if the callable returns different ordering.","severity":"breaking","affected_versions":"1.8.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install with 'pip install unittest-parametrize' and import as 'from unittest_parametrize import parametrize'.","cause":"Package not installed or misspelled import.","error":"ModuleNotFoundError: No module named 'unittest_parametrize'"},{"fix":"Use correct import: 'from unittest_parametrize import parametrize'.","cause":"Importing the wrong symbol, e.g., from unittest.parametrize import parametrize.","error":"TypeError: 'parametrize' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}