Skip to content

providers.Configuration(ini_files=...) doesn't seem to work #564

@shimat

Description

@shimat

Hi,
when using providers.Configuration(ini_files=...), the ini file does not seem to be loaded. But from_ini works fine.

My environment: Windows 11, Python 3.10.1, dependency-injector = "4.38.0".

# config.ini
[A]
xxx = foo
yyy = bar
# pytest example
from pathlib import Path
from dependency_injector import providers

def test_configuration():
    assert Path("config.ini").exists() is True

    config1 = providers.Configuration()
    config1.from_ini("./config.ini", required=True)
    assert config1() == {'A': {'xxx': 'foo', 'yyy': 'bar'}}  # OK

    config2 = providers.Configuration(ini_files=["./config.ini"])
    assert config2() == {'A': {'xxx': 'foo', 'yyy': 'bar'}}  # Failure

"""
>       assert config2() == {'A': {'xxx': 'foo', 'yyy': 'bar'}}
E       AssertionError: assert {} == {'A': {'xxx':...'yyy': 'bar'}}
E         Right contains 1 more item:
E         {'A': {'xxx': 'foo', 'yyy': 'bar'}}
E         Full diff:
E         - {'A': {'xxx': 'foo', 'yyy': 'bar'}}
E         + {}
"""

Metadata

Metadata

Assignees

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