34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from collections import Counter
|
|
|
|
from scripts.ruff_ratchet import normalized_findings
|
|
|
|
|
|
def test_normalized_findings_ignore_line_number_changes(tmp_path):
|
|
source = tmp_path / "sample.py"
|
|
source.write_text("\nvalue = missing\n", encoding="utf-8")
|
|
diagnostics = [
|
|
{
|
|
"filename": str(source),
|
|
"code": "F821",
|
|
"message": "Undefined name `missing`",
|
|
"location": {"row": 2, "column": 9},
|
|
}
|
|
]
|
|
|
|
assert normalized_findings(diagnostics, tmp_path) == Counter(
|
|
{("sample.py", "F821", "Undefined name `missing`", "value = missing"): 1}
|
|
)
|
|
|
|
|
|
def test_normalized_findings_preserve_duplicate_count(tmp_path):
|
|
source = tmp_path / "sample.py"
|
|
source.write_text("missing\n", encoding="utf-8")
|
|
diagnostic = {
|
|
"filename": str(source),
|
|
"code": "F821",
|
|
"message": "Undefined name `missing`",
|
|
"location": {"row": 1, "column": 1},
|
|
}
|
|
|
|
assert normalized_findings([diagnostic, diagnostic], tmp_path).total() == 2
|