purple-umbrella-89891
05/05/2022, 7:16 AMparametrize
to work around my issue with coverage (see here). However I'm not able to use parametrize
on extra_env_vars
.
Here are the options I tried with their respective errors:
# 1st try:
python_tests(
name=name,
extra_env_vars=parametrize(["MODE=1"], ["MODE=2"]),
)
Exception: Failed to parametrize `//:tests0`:
In parametrize(['MODE=1'], ['MODE=2']:
Positional arguments must be strings, but `['MODE=1']` was a `list`.
# 2nd try:
python_tests(
name=name,
extra_env_vars=parametrize("MODE=1", "MODE=2"),
)
Exception: Failed to parametrize `//:tests0`:
In parametrize(MODE=1, MODE=2:
Positional argument `MODE=1` contained separator characters (`=`).
To use `{arg}` as a parameter, you can pass it as a keyword argument to give it an alias. For example: `parametrize(short_memorable_name='{arg}')`
# 3rd try:
python_tests(
name=name,
extra_env_vars=[parametrize("MODE=1", "MODE=2")],
)
InvalidFieldTypeException: The 'extra_env_vars' field in target xyz.py:tests must be an iterable of strings (e.g. a list of strings), but was `[parametrize(MODE=1, MODE=2]` with type `list`.
By the way, a small functionally irrelevant bug in the error output in parametrize.py:59-60, those two lines should be f-strings. (Small PR opened here)witty-crayon-22786
05/05/2022, 4:57 PMextra_env_vars=parametrize(m1=["MODE=1"], m2=["MODE=2"]),
witty-crayon-22786
05/05/2022, 4:58 PMwitty-crayon-22786
05/05/2022, 4:58 PMpurple-umbrella-89891
05/06/2022, 10:51 AMwitty-crayon-22786
05/06/2022, 4:51 PMwitty-crayon-22786
05/06/2022, 5:52 PM