Skip to content

Override appending doesn't override empty settings #3100

@stefanor

Description

@stefanor

Issue

In my work in #3088, I got appending working, but didn't correctly handle the case where there is no existing configuration parameter to append to.

It wasn't obvious that a KeyError gets raised early in load() in this case, and bypasses my appending logic.

This breaks my entire use-case for #3087. Whoops!

Minimal example

$ cat > setup.cfg <<EOL
[metadata]
name = foo

[options]
py_modules = foo
EOL
$ cat > tox.ini <<EOL
[tox]
[testenv]
install_command = python -c 'import os; assert "foo" in os.environ'
EOL
$ tox -e py311 -x testenv.setenv=foo=bar
...
  py311: OK (0.48 seconds)
  congratulations :) (0.60 seconds)
$ tox -e py311 -x testenv.setenv+=foo=bar
...
py311: install_package> python -c 'import os; assert "foo" in os.environ' --force-reinstall --no-deps /tmp/toxhax/.tox/.tmp/package/3/foo-0.0.0.tar.gz
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AssertionError
...
$ cat >> tox.ini << EOL
> setenv =
>   bar=baz
> EOL
$ tox -e py311 -x testenv.setenv+=foo=bar
...
  py311: OK (0.45 seconds)
  congratulations :) (0.57 seconds)

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