Marco Ricci commited on 2025-02-05 11:52:22
Zeige 3 geänderte Dateien mit 13 Einfügungen und 19 Löschungen.
Ensure that when writing out the configuration, we add indents and linebreaks.
... | ... |
@@ -296,7 +296,9 @@ def save_config(config: _types.VaultConfig, /) -> None: |
296 | 296 |
filedir = filename.resolve().parent |
297 | 297 |
filedir.mkdir(parents=True, exist_ok=True) |
298 | 298 |
with filename.open('w', encoding='UTF-8') as fileobj: |
299 |
- json.dump(config, fileobj) |
|
299 |
+ json.dump( |
|
300 |
+ config, fileobj, ensure_ascii=False, indent=2, sort_keys=True |
|
301 |
+ ) |
|
300 | 302 |
|
301 | 303 |
|
302 | 304 |
def load_user_config() -> dict[str, Any]: |
... | ... |
@@ -297,7 +297,9 @@ def derivepassphrase_export_vault( |
297 | 297 |
) |
298 | 298 |
ctx.exit(1) |
299 | 299 |
click.echo( |
300 |
- json.dumps(config, indent=2, sort_keys=True), |
|
300 |
+ json.dumps( |
|
301 |
+ config, ensure_ascii=False, indent=2, sort_keys=True |
|
302 |
+ ), |
|
301 | 303 |
color=ctx.color, |
302 | 304 |
) |
303 | 305 |
break |
... | ... |
@@ -1227,7 +1229,13 @@ def derivepassphrase_vault( # noqa: C901,PLR0912,PLR0913,PLR0914,PLR0915 |
1227 | 1229 |
prog_name_list=prog_name_pieces, |
1228 | 1230 |
) |
1229 | 1231 |
else: |
1230 |
- json.dump(configuration, outfile) |
|
1232 |
+ json.dump( |
|
1233 |
+ configuration, |
|
1234 |
+ outfile, |
|
1235 |
+ ensure_ascii=False, |
|
1236 |
+ indent=2, |
|
1237 |
+ sort_keys=True, |
|
1238 |
+ ) |
|
1231 | 1239 |
except OSError as exc: |
1232 | 1240 |
err( |
1233 | 1241 |
_msg.TranslatedString( |
... | ... |
@@ -2111,10 +2111,6 @@ class TestCLI: |
2111 | 2111 |
'expected error exit and known error message' |
2112 | 2112 |
) |
2113 | 2113 |
|
2114 |
- @pytest.mark.xfail( |
|
2115 |
- reason='config are currently stored as single lines', |
|
2116 |
- raises=AssertionError, |
|
2117 |
- ) |
|
2118 | 2114 |
@Parametrize.VALID_TEST_CONFIGS |
2119 | 2115 |
def test_213_import_config_success( |
2120 | 2116 |
self, |
... | ... |
@@ -2153,10 +2149,6 @@ class TestCLI: |
2153 | 2149 |
), 'unexpected error output' |
2154 | 2150 |
assert_vault_config_is_indented_and_line_broken(config_txt) |
2155 | 2151 |
|
2156 |
- @pytest.mark.xfail( |
|
2157 |
- reason='config are currently stored as single lines', |
|
2158 |
- raises=AssertionError, |
|
2159 |
- ) |
|
2160 | 2152 |
@hypothesis.settings( |
2161 | 2153 |
suppress_health_check=[ |
2162 | 2154 |
*hypothesis.settings().suppress_health_check, |
... | ... |
@@ -2306,10 +2298,6 @@ class TestCLI: |
2306 | 2298 |
'expected error exit and known error message' |
2307 | 2299 |
) |
2308 | 2300 |
|
2309 |
- @pytest.mark.xfail( |
|
2310 |
- reason='config exports are currently single-line', |
|
2311 |
- raises=AssertionError, |
|
2312 |
- ) |
|
2313 | 2301 |
@Parametrize.VALID_TEST_CONFIGS |
2314 | 2302 |
def test_214_export_config_success( |
2315 | 2303 |
self, |
... | ... |
@@ -2655,10 +2643,6 @@ contents go here |
2655 | 2643 |
config = json.load(infile) |
2656 | 2644 |
assert config == {'global': {'phrase': 'abc'}, 'services': {}} |
2657 | 2645 |
|
2658 |
- @pytest.mark.xfail( |
|
2659 |
- reason='config are currently stored as single lines', |
|
2660 |
- raises=AssertionError, |
|
2661 |
- ) |
|
2662 | 2646 |
@Parametrize.CONFIG_EDITING_VIA_CONFIG_FLAG |
2663 | 2647 |
def test_224_store_config_good( |
2664 | 2648 |
self, |
2665 | 2649 |