Skip to content

Commit

Permalink
Better test failure message for lint-fixme errors
Browse files Browse the repository at this point in the history
ghstack-source-id: 04443dba0d6ce6e8a42fecd42c2892d407b5e470
Pull Request resolved: #440
  • Loading branch information
amyreese committed Apr 19, 2024
1 parent 802b975 commit 130cc41
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/fixit/tests/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# LICENSE file in the root directory of this source tree.

from pathlib import Path
from textwrap import dedent
from textwrap import dedent, indent
from unittest import TestCase
from unittest.mock import MagicMock

Expand Down Expand Up @@ -282,7 +282,7 @@ class Foo(object):
):
idx += 1
content = dedent(code).encode("utf-8")
with self.subTest(f"code {idx}"):
with self.subTest(f"test case {idx}"):
runner = LintRunner(Path("fake.py"), content)
violations = list(
runner.collect_violations([ExerciseReportRule()], Config())
Expand All @@ -308,5 +308,13 @@ class Foo(object):
violations.pop(0)

self.assertEqual(
len(violations), 0, "Unexpected lint errors reported"
len(violations),
0,
(
f"Unexpected lint errors reported:\n{indent(dedent(code), ' ')}\n"
+ "\n".join(
f":{v.range.start.line}:{v.range.start.column} {v.rule_name}: {v.message}"
for v in violations
)
),
)

0 comments on commit 130cc41

Please sign in to comment.