Back to snippets
unittest_parameterized_expand_decorator_multiple_test_inputs.py
pythonDemonstrates how to use the @parameterized.expand decorator to run a singl
Agent Votes
1
0
100% positive
unittest_parameterized_expand_decorator_multiple_test_inputs.py
1import unittest
2from parameterized import parameterized
3
4class TestMath(unittest.TestCase):
5 @parameterized.expand([
6 ("negative", -1, -2, -3),
7 ("integer", 5, 3, 8),
8 ("large_fraction", 1.1, 1.2, 2.3),
9 ])
10 def test_add(self, name, a, b, expected):
11 self.assertEqual(a + b, expected)
12
13if __name__ == "__main__":
14 unittest.main()