11"""Tests to track CLI documentation coverage.
22
3- These tests verify that options intended to be documented have:
4- 1. A cli_doc marker in tests
5- 2. An entry in CLI_OPTION_META
3+ These tests verify that all CLI options (defined in arguments.py) have
4+ a cli_doc marker in tests (unless in MANUAL_DOCS).
65
7- The DOCUMENTED_OPTIONS set defines which options should be documented.
8- This allows gradual expansion of documentation coverage.
6+ This ensures that every CLI option has corresponding test documentation.
97"""
108
119from __future__ import annotations
2523
2624COLLECTION_PATH = Path (__file__ ).parent / ".cli_doc_collection.json"
2725
28- # Options that should be documented (gradually expand this set)
29- # Options in this set MUST have:
30- # 1. A cli_doc marker in tests
31- # 2. An entry in CLI_OPTION_META
32- DOCUMENTED_OPTIONS : frozenset [str ] = frozenset ({
33- "--frozen-dataclasses" ,
34- # Add more as cli_doc markers are added to tests...
35- })
36-
3726
3827@pytest .fixture (scope = "module" )
3928def collection_data () -> dict [str , Any ]: # pragma: no cover
@@ -57,34 +46,27 @@ def collected_options(collection_data: dict[str, Any]) -> set[str]: # pragma: n
5746class TestCLIDocCoverage : # pragma: no cover
5847 """Documentation coverage tests."""
5948
60- def test_documented_options_have_cli_doc_markers ( # noqa: PLR6301
49+ def test_all_options_have_cli_doc_markers ( # noqa: PLR6301
6150 self , collected_options : set [str ]
6251 ) -> None :
63- """Verify that DOCUMENTED_OPTIONS have cli_doc markers in tests."""
64- missing = DOCUMENTED_OPTIONS - collected_options
52+ """Verify that all CLI options (except MANUAL_DOCS) have cli_doc markers."""
53+ all_options = get_all_canonical_options ()
54+ documentable_options = all_options - MANUAL_DOCS
55+ missing = documentable_options - collected_options
6556 if missing :
6657 pytest .fail (
67- "Options in DOCUMENTED_OPTIONS but missing cli_doc marker:\n "
58+ "CLI options missing cli_doc marker:\n "
6859 + "\n " .join (f" - { opt } " for opt in sorted (missing ))
6960 + "\n \n Add @pytest.mark.cli_doc(...) to tests for these options."
7061 )
7162
72- def test_documented_options_have_meta (self ) -> None : # noqa: PLR6301
73- """Verify that DOCUMENTED_OPTIONS have CLI_OPTION_META entries."""
74- missing = DOCUMENTED_OPTIONS - set (CLI_OPTION_META .keys ())
75- if missing :
76- pytest .fail (
77- "Options in DOCUMENTED_OPTIONS but missing CLI_OPTION_META:\n "
78- + "\n " .join (f" - { opt } " for opt in sorted (missing ))
79- + "\n \n Add entries to CLI_OPTION_META in cli_options.py."
80- )
81-
82- def test_documented_options_not_manual (self ) -> None : # noqa: PLR6301
83- """Verify that DOCUMENTED_OPTIONS are not in MANUAL_DOCS."""
84- overlap = DOCUMENTED_OPTIONS & MANUAL_DOCS
63+ def test_meta_options_not_manual (self ) -> None : # noqa: PLR6301
64+ """Verify that CLI_OPTION_META options are not in MANUAL_DOCS."""
65+ meta_options = set (CLI_OPTION_META .keys ())
66+ overlap = meta_options & MANUAL_DOCS
8567 if overlap :
8668 pytest .fail (
87- "Options in both DOCUMENTED_OPTIONS and MANUAL_DOCS:\n "
69+ "Options in both CLI_OPTION_META and MANUAL_DOCS:\n "
8870 + "\n " .join (f" - { opt } " for opt in sorted (overlap ))
8971 )
9072
0 commit comments