Skip to content

Commit

Permalink
Fix key sorting for json.dumps in conda config (#13076)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Sep 9, 2023
1 parent 0a2244f commit 8faf745
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion conda/cli/main_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def execute_config(args, parser):
if context.json:
stdout_write(
json.dumps(
context.collect_all(),
{
str(source): values
for source, values in context.collect_all().items()
},
sort_keys=True,
indent=2,
separators=(",", ": "),
Expand Down
19 changes: 19 additions & 0 deletions news/13076-json-sort-pathlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Fix sorting error for `conda config --show-sources --json`. (#13076)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
8 changes: 8 additions & 0 deletions tests/cli/test_main_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ def test_config_get_missing(
assert Path(parsed["rc_path"]) == path
assert parsed["success"]
assert "warnings" in parsed


def test_config_show_sources_json(conda_cli: CondaCLIFixture):
stdout, stderr, err = conda_cli("config", "--show-sources", "--json")
parsed = json.loads(stdout.strip())
assert "error" not in parsed # not an error rendered as a json
assert not stderr
assert not err

0 comments on commit 8faf745

Please sign in to comment.