@@ -138,6 +138,33 @@ def test_good_module_name(self):
138138 self .assertEqual (dialog .entry_error ['text' ], '' )
139139
140140
141+ class GotoTest (unittest .TestCase ):
142+ "Test Goto subclass of Query."
143+
144+ class Dummy_ModuleName :
145+ entry_ok = query .Goto .entry_ok # Function being tested.
146+ def __init__ (self , dummy_entry ):
147+ self .entry = Var (value = dummy_entry )
148+ self .entry_error = {'text' : '' }
149+ def showerror (self , message ):
150+ self .entry_error ['text' ] = message
151+
152+ def test_bogus_goto (self ):
153+ dialog = self .Dummy_ModuleName ('a' )
154+ self .assertEqual (dialog .entry_ok (), None )
155+ self .assertIn ('not a base 10 integer' , dialog .entry_error ['text' ])
156+
157+ def test_bad_goto (self ):
158+ dialog = self .Dummy_ModuleName ('0' )
159+ self .assertEqual (dialog .entry_ok (), None )
160+ self .assertIn ('not a positive integer' , dialog .entry_error ['text' ])
161+
162+ def test_good_goto (self ):
163+ dialog = self .Dummy_ModuleName ('1' )
164+ self .assertEqual (dialog .entry_ok (), 1 )
165+ self .assertEqual (dialog .entry_error ['text' ], '' )
166+
167+
141168# 3 HelpSource test classes each test one method.
142169
143170class HelpsourceBrowsefileTest (unittest .TestCase ):
@@ -363,6 +390,22 @@ def test_click_module_name(self):
363390 root .destroy ()
364391
365392
393+ class GotoGuiTest (unittest .TestCase ):
394+
395+ @classmethod
396+ def setUpClass (cls ):
397+ requires ('gui' )
398+
399+ def test_click_module_name (self ):
400+ root = Tk ()
401+ root .withdraw ()
402+ dialog = query .Goto (root , 'T' , 't' , _utest = True )
403+ dialog .entry .insert (0 , '22' )
404+ dialog .button_ok .invoke ()
405+ self .assertEqual (dialog .result , 22 )
406+ root .destroy ()
407+
408+
366409class HelpsourceGuiTest (unittest .TestCase ):
367410
368411 @classmethod
0 commit comments