This is a generic question geared towards unit testing specifically in Python. Is it acceptable to place 20 or some number of inputs to test in a dictionary as keys, where the values are the expected result output from the function?
I can't find an answer after scouring the internet. Almost everything I read were toy examples like adding numbers to obtain a sum or concatenating a first and last name. The following is another toyish example to describe my question in a simple way.
import unittest
import some_module
class SomeModuleUnitTest(unittest.TestCase):
def test_some_function(self):
input_output_dict = {
1: 1,
2: 4,
3: 9,
4: 16,
5: 25,
6: 36,
7: 49,
.
.
.
20: 400
}
for input_case, output_expected in input_output_dict.items():
output_actual = some_module.some_function(input_case)
self.assertEqual(output_expected, output_actual)
If this is considered archaic, what would be the Pythonic solution for testing multiple inputs?