Skip to content

Commit

Permalink
session.env_select.CliEnv: Document and test spaces behaviour (#3208)
Browse files Browse the repository at this point in the history
It turns out that spaces on either side of environment names in a
comma-separated list are considered not part of the environment
name and removed. This was neither documented nor tested
directly; that's now fixed. (It was and is still also tested in
`config.cli.test_cli_ini.test_ini_exhaustive_parallel_values` as
well.)

The discovery of this was documented in issue #3207.
  • Loading branch information
0cjs committed Jan 27, 2024
1 parent 47fa093 commit 387834a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tox/session/env_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@


class CliEnv: # noqa: PLW1641
"""A `CliEnv` is the user's selection of tox test environments, usually supplied via the ``-e`` command-line
option. It may be treated as a sequence if it's not a "default" or "all" selection.
"""A `CliEnv` is the user's selection of tox test environments, usually supplied via the ``-e`` command-line option
or in a TOML file (typically ``env_list`` in ``tox.ini``). It may be treated as a sequence if it's not a "default"
or "all" selection.
It is in one of three forms:
- A list of specific environments, instantiated with a string that is a comma-separated list of the environment
names. As a sequence this will be a sequence of those names.
names. (These may have spaces on either side of the commas which are removed.) As a sequence this will be a
sequence of those names.
- "ALL" which is all environments defined by the tox configuration. This is instantiated with ``ALL`` either
alone or as any element of a comma-separated list; any other environment names are ignored. `is_all()` will be
Expand Down
1 change: 1 addition & 0 deletions tests/session/test_env_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
("", (), False, True),
("a1", ("a1",), False, False),
("a1,b2,c3", ("a1", "b2", "c3"), False, False),
(" a1, b2 , c3 ", ("a1", "b2", "c3"), False, False),
# If the user gives "ALL" as any envname, this becomes an "is_all" and other envnames are ignored.
("ALL", (), True, False),
("a1,ALL,b2", (), True, False),
Expand Down

0 comments on commit 387834a

Please sign in to comment.