@@ -33,10 +33,10 @@ def cleanup_root():
3333
3434class CountLinesTest (unittest .TestCase ):
3535 """Tests for the count_lines_with_wrapping function."""
36- def check (self , expected , text , linewidth , tabwidth ):
36+ def check (self , expected , text , linewidth ):
3737 return self .assertEqual (
3838 expected ,
39- count_lines_with_wrapping (text , linewidth , tabwidth ),
39+ count_lines_with_wrapping (text , linewidth ),
4040 )
4141
4242 def test_count_empty (self ):
@@ -55,37 +55,14 @@ def test_count_several_lines(self):
5555 """Test with several lines of text."""
5656 self .assertEqual (count_lines_with_wrapping ("1\n 2\n 3\n " ), 3 )
5757
58- def test_tab_width (self ):
59- """Test with various tab widths and line widths."""
60- self .check (expected = 1 , text = '\t ' * 1 , linewidth = 8 , tabwidth = 4 )
61- self .check (expected = 1 , text = '\t ' * 2 , linewidth = 8 , tabwidth = 4 )
62- self .check (expected = 2 , text = '\t ' * 3 , linewidth = 8 , tabwidth = 4 )
63- self .check (expected = 2 , text = '\t ' * 4 , linewidth = 8 , tabwidth = 4 )
64- self .check (expected = 3 , text = '\t ' * 5 , linewidth = 8 , tabwidth = 4 )
65-
66- # test longer lines and various tab widths
67- self .check (expected = 4 , text = '\t ' * 10 , linewidth = 12 , tabwidth = 4 )
68- self .check (expected = 10 , text = '\t ' * 10 , linewidth = 12 , tabwidth = 8 )
69- self .check (expected = 2 , text = '\t ' * 4 , linewidth = 10 , tabwidth = 3 )
70-
71- # test tabwidth=1
72- self .check (expected = 2 , text = '\t ' * 9 , linewidth = 5 , tabwidth = 1 )
73- self .check (expected = 2 , text = '\t ' * 10 , linewidth = 5 , tabwidth = 1 )
74- self .check (expected = 3 , text = '\t ' * 11 , linewidth = 5 , tabwidth = 1 )
75-
76- # test for off-by-one errors
77- self .check (expected = 2 , text = '\t ' * 6 , linewidth = 12 , tabwidth = 4 )
78- self .check (expected = 3 , text = '\t ' * 6 , linewidth = 11 , tabwidth = 4 )
79- self .check (expected = 2 , text = '\t ' * 6 , linewidth = 13 , tabwidth = 4 )
80-
8158 def test_empty_lines (self ):
82- self .check (expected = 1 , text = '\n ' , linewidth = 80 , tabwidth = 8 )
83- self .check (expected = 2 , text = '\n \n ' , linewidth = 80 , tabwidth = 8 )
84- self .check (expected = 10 , text = '\n ' * 10 , linewidth = 80 , tabwidth = 8 )
59+ self .check (expected = 1 , text = '\n ' , linewidth = 80 )
60+ self .check (expected = 2 , text = '\n \n ' , linewidth = 80 )
61+ self .check (expected = 10 , text = '\n ' * 10 , linewidth = 80 )
8562
8663 def test_long_line (self ):
87- self .check (expected = 3 , text = 'a' * 200 , linewidth = 80 , tabwidth = 8 )
88- self .check (expected = 3 , text = 'a' * 200 + '\n ' , linewidth = 80 , tabwidth = 8 )
64+ self .check (expected = 3 , text = 'a' * 200 , linewidth = 80 )
65+ self .check (expected = 3 , text = 'a' * 200 + '\n ' , linewidth = 80 )
8966
9067 def test_several_lines_different_lengths (self ):
9168 text = dedent ("""\
@@ -94,12 +71,11 @@ def test_several_lines_different_lengths(self):
9471
9572 7 chars
9673 13 characters""" )
97- self .check (expected = 5 , text = text , linewidth = 80 , tabwidth = 8 )
98- self .check (expected = 5 , text = text + '\n ' , linewidth = 80 , tabwidth = 8 )
99- self .check (expected = 6 , text = text , linewidth = 40 , tabwidth = 8 )
100- self .check (expected = 7 , text = text , linewidth = 20 , tabwidth = 8 )
101- self .check (expected = 11 , text = text , linewidth = 10 , tabwidth = 8 )
102-
74+ self .check (expected = 5 , text = text , linewidth = 80 )
75+ self .check (expected = 5 , text = text + '\n ' , linewidth = 80 )
76+ self .check (expected = 6 , text = text , linewidth = 40 )
77+ self .check (expected = 7 , text = text , linewidth = 20 )
78+ self .check (expected = 11 , text = text , linewidth = 10 )
10379
10480class SqueezerTest (unittest .TestCase ):
10581 """Tests for the Squeezer class."""
@@ -117,7 +93,6 @@ def make_squeezer_instance(self, editor_window=None):
11793 editor_window = self .make_mock_editor_window ()
11894 squeezer = Squeezer (editor_window )
11995 squeezer .get_line_width = Mock (return_value = 80 )
120- squeezer .editwin .get_tk_tabwidth = Mock (return_value = 8 )
12196 return squeezer
12297
12398 def make_text_widget (self ):
@@ -132,25 +107,21 @@ def test_count_lines(self):
132107 editwin = self .make_mock_editor_window ()
133108 squeezer = self .make_squeezer_instance (editwin )
134109
135- for text_code , tab_width , line_width , expected in [
136- (r"'\n'" , 8 , 80 , 1 ),
137- (r"'\n' * 3" , 8 , 80 , 3 ),
138- (r"'a' * 40 + '\n'" , 8 , 80 , 1 ),
139- (r"'a' * 80 + '\n'" , 8 , 80 , 1 ),
110+ for text_code , line_width , expected in [
111+ (r"'\n'" , 80 , 1 ),
112+ (r"'\n' * 3" , 80 , 3 ),
113+ (r"'a' * 40 + '\n'" , 80 , 1 ),
114+ (r"'a' * 80 + '\n'" , 80 , 1 ),
140115 # TODO: uncomment the next test case after bpo-35208 is fixed
141- # (r"'a' * 200 + '\n'", 8, 80, 3),
142- (r"'aa\t' * 20" , 8 , 80 , 2 ),
143- (r"'aa\t' * 21" , 8 , 80 , 3 ),
144- (r"'aa\t' * 20" , 8 , 40 , 4 ),
145- (r"'aa\t' * 20" , 4 , 80 , 1 ),
146- (r"'aa\t' * 21" , 4 , 80 , 2 ),
116+ # (r"'a' * 200 + '\n'", 80, 3),
117+ (r"'aa\t' * 20" , 80 , 2 ),
118+ (r"'aa\t' * 21" , 80 , 3 ),
119+ (r"'aa\t' * 20" , 40 , 4 ),
147120 ]:
148121 with self .subTest (text_code = text_code ,
149- tab_width = tab_width ,
150122 line_width = line_width ,
151123 expected = expected ):
152124 text = eval (text_code )
153- editwin .get_tk_tabwidth .return_value = tab_width
154125 squeezer .get_line_width .return_value = line_width
155126 self .assertEquals (squeezer .count_lines (text ), expected )
156127
0 commit comments