The question regards parametrization of PyTest and DataFrame custom functions applied using decorators. Let's assume, there are some columns: col_1, col_2 and some methods func_1, func_2 and we want to parametrize a test to ran a func_1 on the col_1, func_2 on the col_2, and so on...
Is it possible to parametrize the function name (similar to column_name parameter) that we want to execute in Unit Test ?
DataFrame.custom = property(custom)
class TestExtractor():
@pytest.mark.parametrize(
"column_name",
[
'col1',
'col2'
]
)
def test_col(self, spark, df, column_name):
# ACT
df_res = df \
.custom.func_1() \ # but it is enought to execute func_1() for col_1
.custom.func_2() \ # but it is enought to execute func_2() for col_2
.select(column_name)
....