@@ -467,11 +467,7 @@ def test_wrap(self):
467467
468468 def test_bbox (self ):
469469 widget = self .create ()
470- bbox = widget .bbox (0 )
471- self .assertEqual (len (bbox ), 4 )
472- for item in bbox :
473- self .assertIsInstance (item , int )
474-
470+ self .assertIsBoundingBox (widget .bbox (0 ))
475471 self .assertRaises (tkinter .TclError , widget .bbox , 'noindex' )
476472 self .assertRaises (tkinter .TclError , widget .bbox , None )
477473 self .assertRaises (TypeError , widget .bbox )
@@ -624,11 +620,7 @@ def test_wrap(self):
624620
625621 def test_bbox (self ):
626622 widget = self .create ()
627- bbox = widget .bbox ('1.1' )
628- self .assertEqual (len (bbox ), 4 )
629- for item in bbox :
630- self .assertIsInstance (item , int )
631-
623+ self .assertIsBoundingBox (widget .bbox ('1.1' ))
632624 self .assertIsNone (widget .bbox ('end' ))
633625 self .assertRaises (tkinter .TclError , widget .bbox , 'noindex' )
634626 self .assertRaises (tkinter .TclError , widget .bbox , None )
@@ -785,6 +777,46 @@ def test_itemconfigure_selectbackground(self):
785777 def test_itemconfigure_selectforeground (self ):
786778 self .check_itemconfigure ('selectforeground' , '#654321' )
787779
780+ def test_box (self ):
781+ lb = self .create ()
782+ lb .insert (0 , * ('el%d' % i for i in range (8 )))
783+ lb .pack ()
784+ self .assertIsBoundingBox (lb .bbox (0 ))
785+ self .assertIsNone (lb .bbox (- 1 ))
786+ self .assertIsNone (lb .bbox (10 ))
787+ self .assertRaises (TclError , lb .bbox , 'noindex' )
788+ self .assertRaises (TclError , lb .bbox , None )
789+ self .assertRaises (TypeError , lb .bbox )
790+ self .assertRaises (TypeError , lb .bbox , 0 , 1 )
791+
792+ def test_curselection (self ):
793+ lb = self .create ()
794+ lb .insert (0 , * ('el%d' % i for i in range (8 )))
795+ lb .selection_clear (0 , tkinter .END )
796+ lb .selection_set (2 , 4 )
797+ lb .selection_set (6 )
798+ self .assertEqual (lb .curselection (), (2 , 3 , 4 , 6 ))
799+ self .assertRaises (TypeError , lb .curselection , 0 )
800+
801+ def test_get (self ):
802+ lb = self .create ()
803+ lb .insert (0 , * ('el%d' % i for i in range (8 )))
804+ self .assertEqual (lb .get (0 ), 'el0' )
805+ self .assertEqual (lb .get (3 ), 'el3' )
806+ self .assertEqual (lb .get ('end' ), 'el7' )
807+ self .assertEqual (lb .get (8 ), '' )
808+ self .assertEqual (lb .get (- 1 ), '' )
809+ self .assertEqual (lb .get (3 , 5 ), ('el3' , 'el4' , 'el5' ))
810+ self .assertEqual (lb .get (5 , 'end' ), ('el5' , 'el6' , 'el7' ))
811+ self .assertEqual (lb .get (5 , 0 ), ())
812+ self .assertEqual (lb .get (0 , 0 ), ('el0' ,))
813+ self .assertRaises (TclError , lb .get , 'noindex' )
814+ self .assertRaises (TclError , lb .get , None )
815+ self .assertRaises (TypeError , lb .get )
816+ self .assertRaises (TclError , lb .get , 'end' , 'noindex' )
817+ self .assertRaises (TypeError , lb .get , 1 , 2 , 3 )
818+ self .assertRaises (TclError , lb .get , 2.4 )
819+
788820
789821@add_standard_options (PixelSizeTests , StandardOptionsTests )
790822class ScaleTest (AbstractWidgetTest , unittest .TestCase ):
0 commit comments