Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion donfig/config_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ def __init__(
*[os.path.join(prefix, "etc", name) for prefix in site.PREFIXES],
os.path.join(os.path.expanduser("~"), ".config", name),
]

else:
# copy so the env-var append below never mutates the caller's list
paths = list(paths)
if env_prefix is None:
env_prefix = f"{name.upper()}_"
if env is None:
Expand Down
15 changes: 15 additions & 0 deletions donfig/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,21 @@ def test__get_paths(monkeypatch):
assert len(paths) == len(set(paths))


def test_paths_not_mutated(monkeypatch):
monkeypatch.setenv("MYPKG_CONFIG", "foo-bar")
paths = ["/etc/mypkg"]
config = Config("mypkg", paths=paths)
assert config.paths == ["/etc/mypkg", "foo-bar"]
# the caller's list is copied on init, not aliased
assert paths == ["/etc/mypkg"]


def test_paths_accepts_any_sequence(monkeypatch):
monkeypatch.setenv("MYPKG_CONFIG", "foo-bar")
config = Config("mypkg", paths=("/etc/mypkg",))
assert config.paths == ["/etc/mypkg", "foo-bar"]


def test_serialization():
config = Config(CONFIG_NAME)
config.set(one_key="one_value")
Expand Down