Home | History | Annotate | Download | only in idle_test
      1 import unittest
      2 import os
      3 import sys
      4 import idlelib
      5 from idlelib import PathBrowser
      6 
      7 class PathBrowserTest(unittest.TestCase):
      8 
      9     def test_DirBrowserTreeItem(self):
     10         # Issue16226 - make sure that getting a sublist works
     11         d = PathBrowser.DirBrowserTreeItem('')
     12         d.GetSubList()
     13         self.assertEqual('', d.GetText())
     14 
     15         dir = os.path.split(os.path.abspath(idlelib.__file__))[0]
     16         self.assertEqual(d.ispackagedir(dir), True)
     17         self.assertEqual(d.ispackagedir(dir + '/Icons'), False)
     18 
     19     def test_PathBrowserTreeItem(self):
     20         p = PathBrowser.PathBrowserTreeItem()
     21         self.assertEqual(p.GetText(), 'sys.path')
     22         sub = p.GetSubList()
     23         self.assertEqual(len(sub), len(sys.path))
     24         # Following fails in 2.7 because old-style class
     25         #self.assertEqual(type(sub[0]), PathBrowser.DirBrowserTreeItem)
     26 
     27 if __name__ == '__main__':
     28     unittest.main(verbosity=2, exit=False)
     29