Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configuration provider's set method can't reset override #319

Closed
lust4life opened this issue Nov 5, 2020 · 2 comments
Closed

configuration provider's set method can't reset override #319

lust4life opened this issue Nov 5, 2020 · 2 comments
Assignees
Labels

Comments

@lust4life
Copy link

lust4life commented Nov 5, 2020

https://github.com/ets-labs/python-dependency-injector/blob/master/src/dependency_injector/providers.pyx#L1389-L1400

maybe here we should deep copy the original value then modify it ?

or is this (not support reset override) expected behavior?

def test_configuration_set():
    from dependency_injector import providers

    config = providers.Configuration(
        name="config", default={"a": {"b": {"c": 1, "d": 2}}}
    )
    assert config.a.b.c() == 1

    with config.set("a.b.c", "xxx"):
        assert config.a.b.c() == "xxx"
    assert config.a.b.c() == 1  # will fail here, AssertionError: assert 'xxx' == 1

    with config.a.b.c.override("yyy"):
        assert config.a.b.c() == "yyy"

    assert config.a.b.c() == 1  # will fail here, AssertionError: assert 'yyy' == 1
@rmk135 rmk135 self-assigned this Nov 5, 2020
@rmk135 rmk135 added the bug label Nov 5, 2020
@rmk135
Copy link
Member

rmk135 commented Nov 5, 2020

Hi @lust4life , thanks for reporting the issue and suggesting a fix. I've added provided test to the test suite, implemented a fix and released new version 4.3.4.

@rmk135 rmk135 closed this as completed Nov 5, 2020
@lust4life
Copy link
Author

That's really nice! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants