summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorTal Einat <taleinat+github@gmail.com>2018-12-24 12:05:51 (GMT)
committerGitHub <noreply@github.com>2018-12-24 12:05:51 (GMT)
commit44a79cc5b3d1fb0c03c99077aa26def85ec26c67 (patch)
tree6f1cb81c1acec007ff2ea6c8e823b24241e4a5e1 /Lib/idlelib/idle_test
parente7eed78f04085e6cded0cebcc715364b05e8a71b (diff)
downloadcpython-44a79cc5b3d1fb0c03c99077aa26def85ec26c67.zip
cpython-44a79cc5b3d1fb0c03c99077aa26def85ec26c67.tar.gz
cpython-44a79cc5b3d1fb0c03c99077aa26def85ec26c67.tar.bz2
bpo-35208: Fix IDLE Squeezer line counting (GH-10449)
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_squeezer.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/idlelib/idle_test/test_squeezer.py b/Lib/idlelib/idle_test/test_squeezer.py
index ca8b674..da2c2dd 100644
--- a/Lib/idlelib/idle_test/test_squeezer.py
+++ b/Lib/idlelib/idle_test/test_squeezer.py
@@ -1,4 +1,5 @@
from collections import namedtuple
+from textwrap import dedent
from tkinter import Text, Tk
import unittest
from unittest.mock import Mock, NonCallableMagicMock, patch, sentinel, ANY
@@ -77,6 +78,28 @@ class CountLinesTest(unittest.TestCase):
self.check(expected=3, text='\t' * 6, linewidth=11, tabwidth=4)
self.check(expected=2, text='\t' * 6, linewidth=13, tabwidth=4)
+ def test_empty_lines(self):
+ self.check(expected=1, text='\n', linewidth=80, tabwidth=8)
+ self.check(expected=2, text='\n\n', linewidth=80, tabwidth=8)
+ self.check(expected=10, text='\n' * 10, linewidth=80, tabwidth=8)
+
+ def test_long_line(self):
+ self.check(expected=3, text='a' * 200, linewidth=80, tabwidth=8)
+ self.check(expected=3, text='a' * 200 + '\n', linewidth=80, tabwidth=8)
+
+ def test_several_lines_different_lengths(self):
+ text = dedent("""\
+ 13 characters
+ 43 is the number of characters on this line
+
+ 7 chars
+ 13 characters""")
+ self.check(expected=5, text=text, linewidth=80, tabwidth=8)
+ self.check(expected=5, text=text + '\n', linewidth=80, tabwidth=8)
+ self.check(expected=6, text=text, linewidth=40, tabwidth=8)
+ self.check(expected=7, text=text, linewidth=20, tabwidth=8)
+ self.check(expected=11, text=text, linewidth=10, tabwidth=8)
+
class SqueezerTest(unittest.TestCase):
"""Tests for the Squeezer class."""