2323
2424from diffpy .pdfgui .gui .parameterspanel import ParametersPanel
2525from diffpy .pdfgui .control .parameter import Parameter
26- from diffpy .pdfgui .tests .testutils import GUITestCase
26+ from diffpy .pdfgui .tests .testutils import GUITestCase , clickcell
2727
2828# ----------------------------------------------------------------------------
2929
@@ -48,22 +48,6 @@ def tearDown(self):
4848 return
4949
5050
51- def _clickcell (self , leftright , row , col , ** kw ):
52- gp = self .panel .grid_parameters
53- assert leftright in ('left' , 'right' )
54- if leftright == "left" :
55- eventtype = wx .grid .EVT_GRID_CELL_LEFT_CLICK .typeId
56- else :
57- eventtype = wx .grid .EVT_GRID_CELL_RIGHT_CLICK .typeId
58- kbd = {'kbd' : wx .KeyboardState (** kw )}
59- # TODO: remove this after deprecations of wxpython 3
60- if wx .VERSION [0 ] == 3 :
61- kbd = {k .replace ('Down' , '' ): v for k , v in kw .items ()}
62- e = wx .grid .GridEvent (gp .Id , eventtype , gp , row , col , ** kbd )
63- gp .ProcessEvent (e )
64- return
65-
66-
6751 def test_onPopupFixFree (self ):
6852 "Check ParametersPanel.onPopupFixFree"
6953 # event is not used, we just generate and reuse dummy event.
@@ -108,21 +92,21 @@ def test_onCellLeftClick(self):
10892 self .assertFalse (self .panel .mainFrame .altered )
10993 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
11094 self .assertFalse (p .fixed )
111- self . _clickcell ( "left" , 0 , 1 )
95+ clickcell ( gp , "left" , 0 , 1 )
11296 self .assertEqual ("1" , gp .GetCellValue (0 , 1 ))
11397 self .assertTrue (p .fixed )
11498 self .assertTrue (self .panel .mainFrame .altered )
115- self . _clickcell ( "left" , 0 , 1 )
99+ clickcell ( gp , "left" , 0 , 1 )
116100 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
117- self . _clickcell ( "left" , 0 , 1 , controlDown = True )
101+ clickcell ( gp , "left" , 0 , 1 , controlDown = True )
118102 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
119- self . _clickcell ( "left" , 0 , 1 , shiftDown = True )
103+ clickcell ( gp , "left" , 0 , 1 , shiftDown = True )
120104 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
121105 gp .SelectAll ()
122- self . _clickcell ( "left" , 0 , 1 )
106+ clickcell ( gp , "left" , 0 , 1 )
123107 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
124108 gp .ClearSelection ()
125- self . _clickcell ( "left" , 0 , 1 )
109+ clickcell ( gp , "left" , 0 , 1 )
126110 self .assertEqual ("1" , gp .GetCellValue (0 , 1 ))
127111 return
128112
@@ -133,7 +117,7 @@ def test_onCellRightClick(self):
133117 gp = self .panel .grid_parameters
134118 gp .PopupMenu = lambda menu , pos : None
135119 try :
136- self . _clickcell ( "right" , 0 , 1 )
120+ clickcell ( gp , "right" , 0 , 1 )
137121 finally :
138122 del gp .PopupMenu
139123 self .assertTrue (self .panel .did_popupIDs )
0 commit comments