Skip to content

Commit ce40225

Browse files
committed
test: overriding with get_all_enabled
1 parent b5c99d5 commit ce40225

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

tests/test-proselintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lexical_illusions": true,
1111
"malapropisms": true,
1212
"misc": true,
13-
"mixed_metaphors": true,
13+
"mixed_metaphors": true,
1414
"mondegreens": true,
1515
"needless_variants": true,
1616
"nonwords": true,

tests/test_config_flag.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
from proselint.command_line import get_parser, proselint
99
from proselint.config import (
1010
DEFAULT,
11-
_deepmerge_dicts, # pyright: ignore[reportUnknownVariableType, reportPrivateUsage]
11+
_deepmerge_dicts, # pyright: ignore[reportPrivateUsage]
1212
load_from,
1313
)
14+
from proselint.registry import CheckRegistry
1415

1516
CONFIG_FILE = Path(__file__).parent / "test-proselintrc.json"
1617
PARSER = get_parser()
@@ -29,6 +30,44 @@ def test_deepmerge_dicts() -> None:
2930
}
3031

3132

33+
def test_specific_overrides_general() -> None:
34+
"""Test that specific config keys override general ones."""
35+
checks = {
36+
"typography": True,
37+
"typography.symbols": False,
38+
"typography.symbols.curly_quotes": True,
39+
"typography.punctuation.hyperbole": False,
40+
}
41+
42+
registry = CheckRegistry()
43+
enabled = registry.get_all_enabled(checks)
44+
45+
paths = {check.path for check in enabled}
46+
47+
assert any(
48+
"typography.symbols.curly_quotes" in path
49+
for path in paths
50+
)
51+
52+
assert len(
53+
[path for path in paths
54+
if path.startswith("typography.symbols.")
55+
and "curly_quotes" not in path]
56+
) == 0
57+
58+
assert not any(
59+
"typography.punctuation.hyperbole" in path
60+
for path in paths
61+
)
62+
63+
assert any(
64+
path.startswith("typography.")
65+
and not path.startswith("typography.symbols.")
66+
and "hyperbole" not in path
67+
for path in paths
68+
)
69+
70+
3271
def test_load_from() -> None:
3372
"""Test load_options by specifying a user options path."""
3473
overrides = load_from(CONFIG_FILE)

0 commit comments

Comments
 (0)