@@ -206,18 +206,10 @@ def test_get_widget_font_family_and_size(self) -> None:
206206 unittest .main ()
207207
208208
209- class TestRichTextColorAndFontFallbacks ( unittest . TestCase ) :
209+ class TestRichTextColorAndFontFallbacks :
210210 """Tests for color and font fallback behavior in RichText."""
211211
212- def setUp (self ) -> None :
213- self .root = tk .Tk ()
214- self .root .withdraw ()
215-
216- def tearDown (self ) -> None :
217- self .root .update_idletasks ()
218- self .root .destroy ()
219-
220- def test_user_can_create_rich_text_with_explicit_background_color (self ) -> None :
212+ def test_user_can_create_rich_text_with_explicit_background_color (self , root : tk .Tk ) -> None :
221213 """
222214 User can create RichText with an explicit background color.
223215
@@ -226,10 +218,10 @@ def test_user_can_create_rich_text_with_explicit_background_color(self) -> None:
226218 THEN: The background kwarg should skip the auto-detection
227219 AND: Widget should use the provided background color
228220 """
229- rich_text = RichText (self . root , background = "red" )
221+ rich_text = RichText (root , background = "red" )
230222 assert rich_text .cget ("background" ) == "red"
231223
232- def test_user_can_create_rich_text_with_bg_shorthand (self ) -> None :
224+ def test_user_can_create_rich_text_with_bg_shorthand (self , root : tk . Tk ) -> None :
233225 """
234226 User can create RichText with bg shorthand.
235227
@@ -238,11 +230,11 @@ def test_user_can_create_rich_text_with_bg_shorthand(self) -> None:
238230 THEN: The bg kwarg should skip the auto-detection
239231 AND: Widget should use the provided background color
240232 """
241- rich_text = RichText (self . root , bg = "blue" )
233+ rich_text = RichText (root , bg = "blue" )
242234 # Color may be returned as RGB by Tk on some platforms
243235 assert rich_text .cget ("background" )
244236
245- def test_user_can_create_rich_text_with_explicit_foreground_color (self ) -> None :
237+ def test_user_can_create_rich_text_with_explicit_foreground_color (self , root : tk . Tk ) -> None :
246238 """
247239 User can create RichText with an explicit foreground color.
248240
@@ -251,21 +243,21 @@ def test_user_can_create_rich_text_with_explicit_foreground_color(self) -> None:
251243 THEN: The foreground kwarg should skip auto-detection
252244 AND: Widget should use provided foreground color
253245 """
254- rich_text = RichText (self . root , foreground = "green" )
246+ rich_text = RichText (root , foreground = "green" )
255247 assert rich_text .cget ("foreground" )
256248
257- def test_user_can_create_rich_text_with_fg_shorthand (self ) -> None :
249+ def test_user_can_create_rich_text_with_fg_shorthand (self , root : tk . Tk ) -> None :
258250 """
259251 User can create RichText with fg shorthand.
260252
261253 GIVEN: User wants a custom foreground color using 'fg' alias
262254 WHEN: RichText is created with fg kwarg
263255 THEN: Widget should be created successfully
264256 """
265- rich_text = RichText (self . root , fg = "purple" )
257+ rich_text = RichText (root , fg = "purple" )
266258 assert rich_text .cget ("foreground" )
267259
268- def test_user_can_create_rich_text_when_safe_font_nametofont_returns_none (self ) -> None :
260+ def test_user_can_create_rich_text_when_safe_font_nametofont_returns_none (self , root : tk . Tk ) -> None :
269261 """
270262 User can create RichText even when safe_font_nametofont returns None.
271263
@@ -275,7 +267,7 @@ def test_user_can_create_rich_text_when_safe_font_nametofont_returns_none(self)
275267 AND: Widget should be created successfully
276268 """
277269 with patch ("ardupilot_methodic_configurator.frontend_tkinter_rich_text.safe_font_nametofont" , return_value = None ):
278- rich_text = RichText (self . root )
270+ rich_text = RichText (root )
279271
280272 assert rich_text is not None
281273 assert "bold" in rich_text .tag_names ()
0 commit comments