From f5850c0d3a893cbb6d9de192fe8e6e857573499b Mon Sep 17 00:00:00 2001 From: Arik Mitschang Date: Wed, 3 Apr 2024 17:58:46 -0400 Subject: [PATCH] Support multiple override appends (#3261) Currently only the last override supplied is considered, in conflict with now supported append overrides ("+="). This now enables appending multiple times via the command line. --- docs/changelog/3261.feature.rst | 1 + docs/config.rst | 15 +++++- src/tox/config/loader/api.py | 50 ++++++++++--------- tests/config/loader/ini/test_ini_loader.py | 2 +- tests/config/loader/test_loader.py | 6 +++ tests/config/loader/test_memory_loader.py | 2 +- tests/config/test_main.py | 57 ++++++++++++++++++++++ 7 files changed, 108 insertions(+), 25 deletions(-) create mode 100644 docs/changelog/3261.feature.rst diff --git a/docs/changelog/3261.feature.rst b/docs/changelog/3261.feature.rst new file mode 100644 index 000000000..f07f3d74b --- /dev/null +++ b/docs/changelog/3261.feature.rst @@ -0,0 +1 @@ +Add support for multiple appending override options (-x, --override) on command line - by :user:`amitschang`. diff --git a/docs/config.rst b/docs/config.rst index 840924e58..0d40027d6 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -1037,7 +1037,7 @@ You could add additional dependencies by running: .. code-block:: bash - tox --override testenv.deps+=pytest-xdist,pytest-cov + tox --override testenv.deps+=pytest-xdist You could set additional environment variables by running: @@ -1045,6 +1045,19 @@ You could set additional environment variables by running: tox --override testenv.setenv+=baz=quux +You can specify overrides multiple times on the command line to append multiple items: + +.. code-block:: bash + + tox -x testenv.seteenv+=foo=bar -x testenv.setenv+=baz=quux + tox -x testenv.deps+=pytest-xdist -x testenv.deps+=pytest-cov + +Or reset override and append to that (note the first override is ``=`` and not ``+=``): + +.. code-block:: bash + + tox -x testenv.deps=pytest-xdist -x testenv.deps+=pytest-cov + Set CLI flags via environment variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All CLI flags can be set via environment variables too, the naming convention here is ``TOX_