I'm looking into macros and `parametrize` to work ...
# general
p
I'm looking into macros and
parametrize
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:
Copy code
# 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)
1
w
so: you’d need to do something like:
Copy code
extra_env_vars=parametrize(m1=["MODE=1"], m2=["MODE=2"]),
1
it looks like it should work
thanks for the PR!
p
Thanks, that did it :)
w
but yea: i think the “short memorable name” advice should be given in some of the other error cases as well: sorry for the trouble.