mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-11 14:07:46 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
A fork of a third-party project can carry data that is code only by extension (TachiyomiSY's 6000-line exh/eh/tags/*.kt string tables). The reason belongs in that repo next to the data, so the gate now reads a .file-length-exempt of '<glob> # <reason>' lines from its cwd. A glob without a reason is a suppression and exits 2 instead of passing. The package had no tests at all; it now has a suite at 100% line+branch, wired into shared-gates-tests.yml with --cov-fail-under=100. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Yc4TiPjhbQLfH35QBPfrbP
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
"""The shared exemption predicates in file_length.exemptions."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from file_length.config import (
|
|
DATA_TXT_MAX_MEAN_LINE,
|
|
is_data_text,
|
|
is_generated,
|
|
is_session_artifact,
|
|
is_vendored,
|
|
)
|
|
from file_length.tests.conftest import write
|
|
|
|
|
|
def test_generated_by_extension_pattern(tmp_path: Path) -> None:
|
|
assert is_generated(tmp_path / "model.g.dart")
|
|
assert is_generated(tmp_path / "lib" / "generated" / "x.py")
|
|
|
|
|
|
def test_generated_by_header_marker(tmp_path: Path) -> None:
|
|
marked = write(tmp_path, "a.py", "# line\n# @generated by tool\nx = 1\n")
|
|
plain = write(tmp_path, "b.py", "x = 1\n")
|
|
assert is_generated(marked)
|
|
assert not is_generated(plain)
|
|
|
|
|
|
def test_generated_unreadable_is_false(tmp_path: Path) -> None:
|
|
assert not is_generated(tmp_path / "missing.py")
|
|
|
|
|
|
def test_data_text_only_for_short_line_txt(tmp_path: Path) -> None:
|
|
short = int(DATA_TXT_MAX_MEAN_LINE) - 1
|
|
assert is_data_text(tmp_path / "words.txt", lines=10, size=short * 10)
|
|
assert not is_data_text(tmp_path / "prose.txt", lines=10, size=80 * 10)
|
|
assert not is_data_text(tmp_path / "words.py", lines=10, size=10)
|
|
assert not is_data_text(tmp_path / "empty.txt", lines=0, size=0)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"path",
|
|
[
|
|
"/home/u/repo/node_modules/pkg/index.js",
|
|
"/home/u/repo/.claude/skills/x/SKILL.md",
|
|
"/home/u/mcp-servers/servers/foo/main.py",
|
|
"/home/u/aseprite-mcp/src/x.py",
|
|
],
|
|
)
|
|
def test_vendored_paths(path: str) -> None:
|
|
assert is_vendored(Path(path))
|
|
|
|
|
|
def test_own_code_is_not_vendored() -> None:
|
|
assert not is_vendored(Path("/home/u/src/todo/lib/main.dart"))
|
|
assert not is_vendored(Path("/home/u/mcp-servers/session-autopsy/x.py"))
|
|
|
|
|
|
def test_session_artifact() -> None:
|
|
assert is_session_artifact(Path("/home/u/r/docs/superpowers/plans/a.md"))
|
|
assert not is_session_artifact(Path("/home/u/r/docs/README.md"))
|