• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

psf / black / 19746987638

27 Nov 2025 08:13PM UTC coverage: 95.815% (-0.1%) from 95.915%
19746987638

Pull #4749

github

web-flow
Merge ad111d890 into 6ea3ef87b
Pull Request #4749: Upgrade mypy

5149 of 5425 branches covered (94.91%)

7876 of 8220 relevant lines covered (95.82%)

4.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.0
/tests/test_docs.py
1
"""
2

3
Test that the docs are up to date.
4

5
"""
6

7
import re
5✔
8
from collections.abc import Sequence
5✔
9
from itertools import islice
5✔
10
from pathlib import Path
5✔
11

12
import pytest
5✔
13

14
from black.mode import UNSTABLE_FEATURES, Preview
5✔
15

16
DOCS_PATH = Path("docs/the_black_code_style/future_style.md")
5✔
17

18

19
def check_feature_list(
5✔
20
    lines: Sequence[str], expected_feature_names: set[str], label: str
21
) -> str | None:
22
    start_index = lines.index(f"(labels/{label}-features)=\n")
5✔
23
    if start_index == -1:
5!
24
        return (
×
25
            f"Could not find the {label} features list in {DOCS_PATH}. Ensure the"
26
            " preview-features label is present."
27
        )
28
    num_blank_lines_seen = 0
5✔
29
    seen_preview_feature_names = set()
5✔
30
    for line in islice(lines, start_index + 1, None):
5!
31
        if not line.strip():
5✔
32
            num_blank_lines_seen += 1
5✔
33
            if num_blank_lines_seen == 3:
5✔
34
                break
5✔
35
            continue
5✔
36
        if line.startswith("- "):
5✔
37
            match = re.search(r"^- `([a-z\d_]+)`", line)
5✔
38
            if match:
5!
39
                seen_preview_feature_names.add(match.group(1))
5✔
40

41
    if seen_preview_feature_names - expected_feature_names:
5!
42
        extra = ", ".join(sorted(seen_preview_feature_names - expected_feature_names))
×
43
        return (
×
44
            f"The following features should not be in the list of {label} features:"
45
            f" {extra}. Please remove them from the {label}-features label in"
46
            f" {DOCS_PATH}"
47
        )
48
    elif expected_feature_names - seen_preview_feature_names:
5!
49
        missing = ", ".join(sorted(expected_feature_names - seen_preview_feature_names))
×
50
        return (
×
51
            f"The following features are missing from the list of {label} features:"
52
            f" {missing}. Please document them under the {label}-features label in"
53
            f" {DOCS_PATH}"
54
        )
55
    else:
56
        return None
5✔
57

58

59
def test_feature_lists_are_up_to_date() -> None:
5✔
60
    repo_root = Path(__file__).parent.parent
5✔
61
    if not (repo_root / "docs").exists():
5!
62
        pytest.skip("docs not found")
×
63
    with (repo_root / DOCS_PATH).open(encoding="utf-8") as f:
5✔
64
        future_style = f.readlines()
5✔
65
    preview_error = check_feature_list(
5✔
66
        future_style,
67
        {feature.name for feature in set(Preview) - UNSTABLE_FEATURES},
68
        "preview",
69
    )
70
    assert preview_error is None, preview_error
5✔
71
    unstable_error = check_feature_list(
5✔
72
        future_style, {feature.name for feature in UNSTABLE_FEATURES}, "unstable"
73
    )
74
    assert unstable_error is None, unstable_error
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc