Skip to content

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

Closed
@lust4life

Description

@lust4life

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions