Skip to content

Factor parsing is broken when using env vars #3557

@rpkilby

Description

@rpkilby

Issue

Dug a bit into #3555. The first issue was a bit of confusion over the env var naming scheme. The CLI displays a metavar of factor, but the actual argument dest is factors, so the env var lookups are TOXFACTORS/TOX_FACTORS, not TOXFACTOR/TOX_FACTOR. You can't really determine what the env vars should be without looking through the source code, and I don't know if there's an easy or good way to convey this in the CLI help text. Regardless, this was a bit confusing.

As to the actual bug, factor parsing is broken when provided by an env var. I've debugged this as far as I can for now, but essentially it seems that get_env_var converts the env value to a list, but EnvSelector._parse_factors is expecting the raw_factors to be a list of lists. This can be demonstrated with:

 TOX_FACTORS="3.12 django" tox -f 3.13 django r 

Setting a breakpoint in EnvSelector._mark_active, the parsed factors are:

({'o', '1', ' ', 'd', '2', 'g', '3', 'a', 'n', '.', 'j'}, {'3.13', 'django'})

Minimal example

$ tox -f 3.13 l
3.13 -> run the tests with pytest under 3.13
$ TOX_FACTORS=3.13 tox l
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions