MCPcopy Index your code
hub / github.com/python/cpython / test_count_lines

Method test_count_lines

Lib/idlelib/idle_test/test_squeezer.py:116–136  ·  view source on GitHub ↗

Test Squeezer.count_lines() with various inputs.

(self)

Source from the content-addressed store, hash-verified

114 configType, section, option, prev_val)
115
116 def test_count_lines(self):
117 """Test Squeezer.count_lines() with various inputs."""
118 editwin = self.make_mock_editor_window()
119 squeezer = self.make_squeezer_instance(editwin)
120
121 for text_code, line_width, expected in [
122 (r"'\n'", 80, 1),
123 (r"'\n' * 3", 80, 3),
124 (r"'a' * 40 + '\n'", 80, 1),
125 (r"'a' * 80 + '\n'", 80, 1),
126 (r"'a' * 200 + '\n'", 80, 3),
127 (r"'aa\t' * 20", 80, 2),
128 (r"'aa\t' * 21", 80, 3),
129 (r"'aa\t' * 20", 40, 4),
130 ]:
131 with self.subTest(text_code=text_code,
132 line_width=line_width,
133 expected=expected):
134 text = eval(text_code)
135 with patch.object(editwin, 'width', line_width):
136 self.assertEqual(squeezer.count_lines(text), expected)
137
138 def test_init(self):
139 """Test the creation of Squeezer instances."""

Callers

nothing calls this directly

Calls 5

count_linesMethod · 0.80
subTestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected