MCPcopy Index your code
hub / github.com/python/mypy / test_trim_source

Method test_trim_source

mypy/test/testformatter.py:9–51  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7
8class FancyErrorFormattingTestCases(TestCase):
9 def test_trim_source(self) -> None:
10 assert trim_source_line("0123456789abcdef", max_len=16, col=5, min_width=2) == (
11 "0123456789abcdef",
12 0,
13 )
14
15 # Locations near start.
16 assert trim_source_line("0123456789abcdef", max_len=7, col=0, min_width=2) == (
17 "0123456...",
18 0,
19 )
20 assert trim_source_line("0123456789abcdef", max_len=7, col=4, min_width=2) == (
21 "0123456...",
22 0,
23 )
24
25 # Middle locations.
26 assert trim_source_line("0123456789abcdef", max_len=7, col=5, min_width=2) == (
27 "...1234567...",
28 -2,
29 )
30 assert trim_source_line("0123456789abcdef", max_len=7, col=6, min_width=2) == (
31 "...2345678...",
32 -1,
33 )
34 assert trim_source_line("0123456789abcdef", max_len=7, col=8, min_width=2) == (
35 "...456789a...",
36 1,
37 )
38
39 # Locations near the end.
40 assert trim_source_line("0123456789abcdef", max_len=7, col=11, min_width=2) == (
41 "...789abcd...",
42 4,
43 )
44 assert trim_source_line("0123456789abcdef", max_len=7, col=13, min_width=2) == (
45 "...9abcdef",
46 6,
47 )
48 assert trim_source_line("0123456789abcdef", max_len=7, col=15, min_width=2) == (
49 "...9abcdef",
50 6,
51 )
52
53 def test_split_words(self) -> None:
54 assert split_words("Simple message") == ["Simple", "message"]

Callers

nothing calls this directly

Calls 1

trim_source_lineFunction · 0.90

Tested by

no test coverage detected