@@ -56,7 +56,7 @@ def setUpClass(cls):
5656 frame = cls .frame = Frame (root )
5757 text = cls .text = Text (frame )
5858 text .insert ('1.0' , code_sample )
59- # Need to pack for creation of code context label widget.
59+ # Need to pack for creation of code context text widget.
6060 frame .pack (side = 'left' , fill = 'both' , expand = 1 )
6161 text .pack (side = 'top' , fill = 'both' , expand = 1 )
6262 cls .editor = DummyEditwin (root , frame , text )
@@ -75,11 +75,11 @@ def setUp(self):
7575 self .cc = codecontext .CodeContext (self .editor )
7676
7777 def tearDown (self ):
78- if self .cc .label :
79- self .cc .label .destroy ()
78+ if self .cc .context :
79+ self .cc .context .destroy ()
8080 # Explicitly call __del__ to remove scheduled scripts.
8181 self .cc .__del__ ()
82- del self .cc .label , self .cc
82+ del self .cc .context , self .cc
8383
8484 def test_init (self ):
8585 eq = self .assertEqual
@@ -89,7 +89,7 @@ def test_init(self):
8989 eq (cc .editwin , ed )
9090 eq (cc .text , ed .text )
9191 eq (cc .textfont , ed .text ['font' ])
92- self .assertIsNone (cc .label )
92+ self .assertIsNone (cc .context )
9393 eq (cc .info , [(0 , - 1 , '' , False )])
9494 eq (cc .topvisible , 1 )
9595 eq (self .root .tk .call ('after' , 'info' , self .cc .t1 )[1 ], 'timer' )
@@ -120,20 +120,20 @@ def test_toggle_code_context_event(self):
120120 toggle = cc .toggle_code_context_event
121121
122122 # Make sure code context is off.
123- if cc .label :
123+ if cc .context :
124124 toggle ()
125125
126126 # Toggle on.
127127 eq (toggle (), 'break' )
128- self .assertIsNotNone (cc .label )
129- eq (cc .label ['font' ], cc .textfont )
130- eq (cc .label ['fg' ], cc .colors ['foreground' ])
131- eq (cc .label ['bg' ], cc .colors ['background' ])
132- eq (cc .label [ 'text' ] , '' )
128+ self .assertIsNotNone (cc .context )
129+ eq (cc .context ['font' ], cc .textfont )
130+ eq (cc .context ['fg' ], cc .colors ['foreground' ])
131+ eq (cc .context ['bg' ], cc .colors ['background' ])
132+ eq (cc .context . get ( '1.0' , 'end-1c' ) , '' )
133133
134134 # Toggle off.
135135 eq (toggle (), 'break' )
136- self .assertIsNone (cc .label )
136+ self .assertIsNone (cc .context )
137137
138138 def test_get_context (self ):
139139 eq = self .assertEqual
@@ -187,7 +187,7 @@ def test_update_code_context(self):
187187 eq = self .assertEqual
188188 cc = self .cc
189189 # Ensure code context is active.
190- if not cc .label :
190+ if not cc .context :
191191 cc .toggle_code_context_event ()
192192
193193 # Invoke update_code_context without scrolling - nothing happens.
@@ -200,21 +200,21 @@ def test_update_code_context(self):
200200 cc .update_code_context ()
201201 eq (cc .info , [(0 , - 1 , '' , False )])
202202 eq (cc .topvisible , 2 )
203- eq (cc .label [ 'text' ] , '' )
203+ eq (cc .context . get ( '1.0' , 'end-1c' ) , '' )
204204
205205 # Scroll down to line 2.
206206 cc .text .yview (2 )
207207 cc .update_code_context ()
208208 eq (cc .info , [(0 , - 1 , '' , False ), (2 , 0 , 'class C1():' , 'class' )])
209209 eq (cc .topvisible , 3 )
210- eq (cc .label [ 'text' ] , 'class C1():' )
210+ eq (cc .context . get ( '1.0' , 'end-1c' ) , 'class C1():' )
211211
212212 # Scroll down to line 3. Since it's a comment, nothing changes.
213213 cc .text .yview (3 )
214214 cc .update_code_context ()
215215 eq (cc .info , [(0 , - 1 , '' , False ), (2 , 0 , 'class C1():' , 'class' )])
216216 eq (cc .topvisible , 4 )
217- eq (cc .label [ 'text' ] , 'class C1():' )
217+ eq (cc .context . get ( '1.0' , 'end-1c' ) , 'class C1():' )
218218
219219 # Scroll down to line 4.
220220 cc .text .yview (4 )
@@ -223,7 +223,7 @@ def test_update_code_context(self):
223223 (2 , 0 , 'class C1():' , 'class' ),
224224 (4 , 4 , ' def __init__(self, a, b):' , 'def' )])
225225 eq (cc .topvisible , 5 )
226- eq (cc .label [ 'text' ] , 'class C1():\n '
226+ eq (cc .context . get ( '1.0' , 'end-1c' ) , 'class C1():\n '
227227 ' def __init__(self, a, b):' )
228228
229229 # Scroll down to line 11. Last 'def' is removed.
@@ -235,7 +235,7 @@ def test_update_code_context(self):
235235 (8 , 8 , ' if a > b:' , 'if' ),
236236 (10 , 8 , ' elif a < b:' , 'elif' )])
237237 eq (cc .topvisible , 12 )
238- eq (cc .label [ 'text' ] , 'class C1():\n '
238+ eq (cc .context . get ( '1.0' , 'end-1c' ) , 'class C1():\n '
239239 ' def compare(self):\n '
240240 ' if a > b:\n '
241241 ' elif a < b:' )
@@ -249,7 +249,7 @@ def test_update_code_context(self):
249249 (8 , 8 , ' if a > b:' , 'if' ),
250250 (10 , 8 , ' elif a < b:' , 'elif' )])
251251 eq (cc .topvisible , 12 )
252- eq (cc .label [ 'text' ] , 'class C1():\n '
252+ eq (cc .context . get ( '1.0' , 'end-1c' ) , 'class C1():\n '
253253 ' def compare(self):\n '
254254 ' if a > b:\n '
255255 ' elif a < b:' )
@@ -262,12 +262,12 @@ def test_update_code_context(self):
262262 (4 , 4 , ' def __init__(self, a, b):' , 'def' )])
263263 eq (cc .topvisible , 6 )
264264 # context_depth is 1.
265- eq (cc .label [ 'text' ] , ' def __init__(self, a, b):' )
265+ eq (cc .context . get ( '1.0' , 'end-1c' ) , ' def __init__(self, a, b):' )
266266
267267 @mock .patch .object (codecontext .CodeContext , 'update_code_context' )
268268 def test_timer_event (self , mock_update ):
269269 # Ensure code context is not active.
270- if self .cc .label :
270+ if self .cc .context :
271271 self .cc .toggle_code_context_event ()
272272 self .cc .timer_event ()
273273 mock_update .assert_not_called ()
@@ -286,7 +286,7 @@ def test_config_timer_event(self):
286286 test_colors = {'background' : '#222222' , 'foreground' : '#ffff00' }
287287
288288 # Ensure code context is not active.
289- if cc .label :
289+ if cc .context :
290290 cc .toggle_code_context_event ()
291291
292292 # Nothing updates on inactive code context.
@@ -303,28 +303,28 @@ def test_config_timer_event(self):
303303 cc .config_timer_event ()
304304 eq (cc .textfont , save_font )
305305 eq (cc .contextcolors , save_colors )
306- eq (cc .label ['font' ], save_font )
307- eq (cc .label ['background' ], save_colors ['background' ])
308- eq (cc .label ['foreground' ], save_colors ['foreground' ])
306+ eq (cc .context ['font' ], save_font )
307+ eq (cc .context ['background' ], save_colors ['background' ])
308+ eq (cc .context ['foreground' ], save_colors ['foreground' ])
309309
310310 # Active code context, change font.
311311 cc .text ['font' ] = test_font
312312 cc .config_timer_event ()
313313 eq (cc .textfont , test_font )
314314 eq (cc .contextcolors , save_colors )
315- eq (cc .label ['font' ], test_font )
316- eq (cc .label ['background' ], save_colors ['background' ])
317- eq (cc .label ['foreground' ], save_colors ['foreground' ])
315+ eq (cc .context ['font' ], test_font )
316+ eq (cc .context ['background' ], save_colors ['background' ])
317+ eq (cc .context ['foreground' ], save_colors ['foreground' ])
318318
319319 # Active code context, change color.
320320 cc .text ['font' ] = save_font
321321 codecontext .CodeContext .colors = test_colors
322322 cc .config_timer_event ()
323323 eq (cc .textfont , save_font )
324324 eq (cc .contextcolors , test_colors )
325- eq (cc .label ['font' ], save_font )
326- eq (cc .label ['background' ], test_colors ['background' ])
327- eq (cc .label ['foreground' ], test_colors ['foreground' ])
325+ eq (cc .context ['font' ], save_font )
326+ eq (cc .context ['background' ], test_colors ['background' ])
327+ eq (cc .context ['foreground' ], test_colors ['foreground' ])
328328 codecontext .CodeContext .colors = save_colors
329329 cc .config_timer_event ()
330330
0 commit comments