Double Parameterization
So I have a set of tests where I'd like to test multiple versions of a solution. Currently I have import pytest import product_not_at_index functions_to_test = [ product_no
Solution 1:
The solution I ended up using is this one
import pytest
import product_not_at_index
functions_to_test = [product_not_at_index.product_not_at_index_n_squared]
test_data = [
([], []),
([1], [1]),
([1, 1], [1, 1]),
([1, 7, 3, 4], [84, 12, 28, 21]),
]
# TODO: turn into a list comprehension.
test_paramaters = []
for func in functions_to_test:
for test_input, expected_result in test_data:
test_paramaters.append([test_input, expected_result, func])
@pytest.mark.parametrize("function_input,expected_result,test_func", test_paramaters)
def test_run(function_input, expected_result, test_func):
actual_result = test_func(function_input)
assert actual_result == expected_result
Post a Comment for "Double Parameterization"