Marco Ricci commited on 2025-08-29 19:32:37
Zeige 5 geänderte Dateien mit 23 Einfügungen und 30 Löschungen.
(This is part 7 of a series of refactorings for the test suite.) In the command-line interface tests, remove unnecessary imports/aliasing of module-level constants, and add typing casts for our own constants where the syntactical type is not the nominal type. Furthermore, for both the command-line interface machinery and the command-line interface tests, update the hyperlinks to our issue tracker to the equivalent wishlist entry in the documentation, and update the commentary on the completion machinery for the Z Shell, removing links to now-resolved issues in favor of reporting the version number of `click` in which the issues were fixed.
| ... | ... |
@@ -1308,6 +1308,9 @@ class ZshComplete(click.shell_completion.ZshComplete): |
| 1308 | 1308 |
adaptively and "smartly" emit colon-escaped output or not, based on |
| 1309 | 1309 |
whether the completion script will be using it. |
| 1310 | 1310 |
|
| 1311 |
+ As of `click` v8.2.2, the Zsh completion class also adaptively emits |
|
| 1312 |
+ colon-escaped output or not, based on the very same criterion. |
|
| 1313 |
+ |
|
| 1311 | 1314 |
""" |
| 1312 | 1315 |
|
| 1313 | 1316 |
@override |
| ... | ... |
@@ -21,7 +21,7 @@ from __future__ import annotations |
| 21 | 21 |
|
| 22 | 22 |
import base64 |
| 23 | 23 |
import enum |
| 24 |
-from typing import TYPE_CHECKING, Protocol |
|
| 24 |
+from typing import TYPE_CHECKING, Protocol, cast |
|
| 25 | 25 |
|
| 26 | 26 |
from typing_extensions import NamedTuple |
| 27 | 27 |
|
| ... | ... |
@@ -1356,7 +1356,7 @@ DUMMY_KEY3 = SUPPORTED_KEYS["ed448"].public_key_data |
| 1356 | 1356 |
"""A third supported SSH test key (in wire format).""" |
| 1357 | 1357 |
DUMMY_KEY3_B64 = base64.standard_b64encode(DUMMY_KEY3).decode("ASCII")
|
| 1358 | 1358 |
"""A third supported SSH test key (in `authorized_keys` format).""" |
| 1359 |
-DUMMY_CONFIG_SETTINGS = {
|
|
| 1359 |
+DUMMY_CONFIG_SETTINGS = cast("_types.VaultConfigServicesSettings", {
|
|
| 1360 | 1360 |
"length": 10, |
| 1361 | 1361 |
"upper": 1, |
| 1362 | 1362 |
"lower": 1, |
| ... | ... |
@@ -1365,7 +1365,7 @@ DUMMY_CONFIG_SETTINGS = {
|
| 1365 | 1365 |
"space": 1, |
| 1366 | 1366 |
"dash": 1, |
| 1367 | 1367 |
"symbol": 1, |
| 1368 |
-} |
|
| 1368 |
+}) |
|
| 1369 | 1369 |
"""Sample vault settings.""" |
| 1370 | 1370 |
DUMMY_RESULT_PASSPHRASE = b".2V_QJkd o" |
| 1371 | 1371 |
""" |
| ... | ... |
@@ -44,17 +44,9 @@ DUMMY_PASSPHRASE = data.DUMMY_PASSPHRASE |
| 44 | 44 |
DUMMY_CONFIG_SETTINGS = data.DUMMY_CONFIG_SETTINGS |
| 45 | 45 |
DUMMY_RESULT_PASSPHRASE = data.DUMMY_RESULT_PASSPHRASE |
| 46 | 46 |
DUMMY_RESULT_KEY1 = data.DUMMY_RESULT_KEY1 |
| 47 |
-DUMMY_PHRASE_FROM_KEY1_RAW = data.DUMMY_PHRASE_FROM_KEY1_RAW |
|
| 48 |
-DUMMY_PHRASE_FROM_KEY1 = data.DUMMY_PHRASE_FROM_KEY1 |
|
| 49 | 47 |
|
| 50 |
-DUMMY_KEY1 = data.DUMMY_KEY1 |
|
| 51 | 48 |
DUMMY_KEY1_B64 = data.DUMMY_KEY1_B64 |
| 52 |
-DUMMY_KEY2 = data.DUMMY_KEY2 |
|
| 53 | 49 |
DUMMY_KEY2_B64 = data.DUMMY_KEY2_B64 |
| 54 |
-DUMMY_KEY3 = data.DUMMY_KEY3 |
|
| 55 |
-DUMMY_KEY3_B64 = data.DUMMY_KEY3_B64 |
|
| 56 |
- |
|
| 57 |
-TEST_CONFIGS = data.TEST_CONFIGS |
|
| 58 | 50 |
|
| 59 | 51 |
|
| 60 | 52 |
class IncompatibleConfiguration(NamedTuple): |
| ... | ... |
@@ -461,7 +453,7 @@ class Parametrize(types.SimpleNamespace): |
| 461 | 453 |
) |
| 462 | 454 |
VALID_TEST_CONFIGS = pytest.mark.parametrize( |
| 463 | 455 |
"config", |
| 464 |
- [conf.config for conf in TEST_CONFIGS if conf.is_valid()], |
|
| 456 |
+ [conf.config for conf in data.TEST_CONFIGS if conf.is_valid()], |
|
| 465 | 457 |
) |
| 466 | 458 |
KEY_OVERRIDING_IN_CONFIG = pytest.mark.parametrize( |
| 467 | 459 |
["config", "command_line"], |
| ... | ... |
@@ -2504,12 +2496,12 @@ class TestStoringConfigurationSuccesses: |
| 2504 | 2496 |
) -> None: |
| 2505 | 2497 |
"""Running without an existing config directory works. |
| 2506 | 2498 |
|
| 2507 |
- This is a regression test; see [issue\u00a0#6][] for context. |
|
| 2508 |
- See also |
|
| 2509 |
- [TestStoringConfigurationFailures001.test_config_directory_not_a_file][] |
|
| 2499 |
+ This is a regression test; see [the "pretty-print-json" |
|
| 2500 |
+ issue][PRETTY_PRINT_JSON] for context. See also |
|
| 2501 |
+ [TestStoringConfigurationFailures.test_config_directory_not_a_file][] |
|
| 2510 | 2502 |
for a related aspect of this. |
| 2511 | 2503 |
|
| 2512 |
- [issue #6]: https://github.com/the-13th-letter/derivepassphrase/issues/6 |
|
| 2504 |
+ [PRETTY_PRINT_JSON]: https://the13thletter.info/derivepassphrase/0.x/wishlist/pretty-print-json/ |
|
| 2513 | 2505 |
|
| 2514 | 2506 |
""" |
| 2515 | 2507 |
runner = machinery.CliRunner(mix_stderr=False) |
| ... | ... |
@@ -2895,12 +2887,12 @@ class TestStoringConfigurationFailures: |
| 2895 | 2887 |
That is, the missing configuration directory does not cause any |
| 2896 | 2888 |
errors by itself. |
| 2897 | 2889 |
|
| 2898 |
- This is a regression test; see [issue\u00a0#6][] for context. |
|
| 2899 |
- See also |
|
| 2900 |
- [TestStoringConfigurationSuccesses001.test_config_directory_nonexistant][] |
|
| 2890 |
+ This is a regression test; see [the "pretty-print-json" |
|
| 2891 |
+ issue][PRETTY_PRINT_JSON] for context. See also |
|
| 2892 |
+ [TestStoringConfigurationSuccesses.test_config_directory_nonexistant][] |
|
| 2901 | 2893 |
for a related aspect of this. |
| 2902 | 2894 |
|
| 2903 |
- [issue #6]: https://github.com/the-13th-letter/derivepassphrase/issues/6 |
|
| 2895 |
+ [PRETTY_PRINT_JSON]: https://the13thletter.info/derivepassphrase/0.x/wishlist/pretty-print-json/ |
|
| 2904 | 2896 |
|
| 2905 | 2897 |
""" |
| 2906 | 2898 |
runner = machinery.CliRunner(mix_stderr=False) |
| ... | ... |
@@ -547,7 +547,9 @@ class TestHelpOutput: |
| 547 | 547 |
|
| 548 | 548 |
(The answer currently is always no. See the |
| 549 | 549 |
[`conventional-configurable-text-styling` wishlist |
| 550 |
- entry](../wishlist/conventional-configurable-text-styling.md).) |
|
| 550 |
+ entry][WISHLIST_ENTRY].) |
|
| 551 |
+ |
|
| 552 |
+ [WISHLIST_ENTRY]: https://the13thletter.info/derivepassphrase/0.x/wishlist/conventional-configurable-text-styling/ |
|
| 551 | 553 |
|
| 552 | 554 |
""" |
| 553 | 555 |
color = False |
| ... | ... |
@@ -60,15 +60,11 @@ def zsh_format(item: click.shell_completion.CompletionItem) -> str: |
| 60 | 60 |
r"""A formatter for `zsh`-style shell completion items. |
| 61 | 61 |
|
| 62 | 62 |
The format is `type<newline>value<newline>help<newline>`, and is |
| 63 |
- dictated by [`click`][]. Upstream `click` currently (v8.2.0) does |
|
| 64 |
- not deal with colons in the value correctly when the help text is |
|
| 65 |
- non-degenerate. Our formatter here does, provided the upstream |
|
| 66 |
- `zsh` completion script is used; see the |
|
| 67 |
- [`cli_machinery.ZshComplete`][] class. A request is underway to |
|
| 68 |
- merge this change into upstream `click`; see |
|
| 69 |
- [`pallets/click#2846`][PR2846]. |
|
| 70 |
- |
|
| 71 |
- [PR2846]: https://github.com/pallets/click/pull/2846 |
|
| 63 |
+ dictated by [`click`][]. Upstream `click` up to and including |
|
| 64 |
+ v8.2.1 does not deal with colons in the value correctly when the |
|
| 65 |
+ help text is non-degenerate. Our formatter here does, provided the |
|
| 66 |
+ upstream `zsh` completion script is used; see the |
|
| 67 |
+ [`cli_machinery.ZshComplete`][] class. |
|
| 72 | 68 |
|
| 73 | 69 |
""" |
| 74 | 70 |
empty_help = "_" |
| 75 | 71 |