Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
tkinter.test.test_ttk.test_widgets.EntryTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_bbox
def test_identify
def test_validation_options
def test_validation
def test_revalidation

Public Attributes

 entry

Detailed Description

Definition at line 204 of file test_widgets.py.


Member Function Documentation

Definition at line 206 of file test_widgets.py.

00206 
00207     def setUp(self):
00208         support.root_deiconify()
00209         self.entry = ttk.Entry()

Here is the caller graph for this function:

Definition at line 210 of file test_widgets.py.

00210 
00211     def tearDown(self):
00212         self.entry.destroy()
00213         support.root_withdraw()
00214 

Here is the caller graph for this function:

Definition at line 215 of file test_widgets.py.

00215 
00216     def test_bbox(self):
00217         self.assertEqual(len(self.entry.bbox(0)), 4)
00218         for item in self.entry.bbox(0):
00219             self.assertTrue(isinstance(item, int))
00220 
00221         self.assertRaises(tkinter.TclError, self.entry.bbox, 'noindex')
00222         self.assertRaises(tkinter.TclError, self.entry.bbox, None)
00223 

Here is the call graph for this function:

Definition at line 224 of file test_widgets.py.

00224 
00225     def test_identify(self):
00226         self.entry.pack()
00227         self.entry.wait_visibility()
00228         self.entry.update_idletasks()
00229 
00230         self.assertEqual(self.entry.identify(5, 5), "textarea")
00231         self.assertEqual(self.entry.identify(-1, -1), "")
00232 
00233         self.assertRaises(tkinter.TclError, self.entry.identify, None, 5)
00234         self.assertRaises(tkinter.TclError, self.entry.identify, 5, None)
00235         self.assertRaises(tkinter.TclError, self.entry.identify, 5, '')
00236 

Here is the call graph for this function:

Definition at line 283 of file test_widgets.py.

00283 
00284     def test_revalidation(self):
00285         def validate(content):
00286             for letter in content:
00287                 if not 'a' <= letter.lower() <= 'z':
00288                     return False
00289             return True
00290 
00291         self.entry['validatecommand'] = self.entry.register(validate), '%P'
00292 
00293         self.entry.insert('end', 'avocado')
00294         self.assertEqual(self.entry.validate(), True)
00295         self.assertEqual(self.entry.state(), ())
00296 
00297         self.entry.delete(0, 'end')
00298         self.assertEqual(self.entry.get(), '')
00299 
00300         self.entry.insert('end', 'a1b')
00301         self.assertEqual(self.entry.validate(), False)
00302         self.assertEqual(self.entry.state(), ('invalid', ))
00303 
00304         self.entry.delete(1)
00305         self.assertEqual(self.entry.validate(), True)
00306         self.assertEqual(self.entry.state(), ())
00307 

Here is the call graph for this function:

Definition at line 265 of file test_widgets.py.

00265 
00266     def test_validation(self):
00267         validation = []
00268         def validate(to_insert):
00269             if not 'a' <= to_insert.lower() <= 'z':
00270                 validation.append(False)
00271                 return False
00272             validation.append(True)
00273             return True
00274 
00275         self.entry['validate'] = 'key'
00276         self.entry['validatecommand'] = self.entry.register(validate), '%S'
00277 
00278         self.entry.insert('end', 1)
00279         self.entry.insert('end', 'a')
00280         self.assertEqual(validation, [False, True])
00281         self.assertEqual(self.entry.get(), 'a')
00282 

Here is the call graph for this function:

Definition at line 237 of file test_widgets.py.

00237 
00238     def test_validation_options(self):
00239         success = []
00240         test_invalid = lambda: success.append(True)
00241 
00242         self.entry['validate'] = 'none'
00243         self.entry['validatecommand'] = lambda: False
00244 
00245         self.entry['invalidcommand'] = test_invalid
00246         self.entry.validate()
00247         self.assertTrue(success)
00248 
00249         self.entry['invalidcommand'] = ''
00250         self.entry.validate()
00251         self.assertEqual(len(success), 1)
00252 
00253         self.entry['invalidcommand'] = test_invalid
00254         self.entry['validatecommand'] = lambda: True
00255         self.entry.validate()
00256         self.assertEqual(len(success), 1)
00257 
00258         self.entry['validatecommand'] = ''
00259         self.entry.validate()
00260         self.assertEqual(len(success), 1)
00261 
00262         self.entry['validatecommand'] = True
00263         self.assertRaises(tkinter.TclError, self.entry.validate)
00264 

Here is the call graph for this function:


Member Data Documentation

Definition at line 208 of file test_widgets.py.


The documentation for this class was generated from the following file: