diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2017-11-23 01:05:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 01:05:35 (GMT) |
commit | ae3c5c7b9e5e5ba53213e12cc100e32415d5762c (patch) | |
tree | 9df879514568b11a8eee141fbe26d859582f9f99 /Lib/idlelib/idle_test/test_pathbrowser.py | |
parent | d7ed48c2b8c11bb99da3661e8fe0bf5ae7f6b8d7 (diff) | |
download | cpython-ae3c5c7b9e5e5ba53213e12cc100e32415d5762c.zip cpython-ae3c5c7b9e5e5ba53213e12cc100e32415d5762c.tar.gz cpython-ae3c5c7b9e5e5ba53213e12cc100e32415d5762c.tar.bz2 |
[3.6] bpo-32100: IDLE: Fix pathbrowser errors; improve tests. (GH-4484) (#4512)
Patch mostly by Cheryl Sabella.
(cherry picked from commit 20d48a44a54ed5e4a6df00e89ae27e3983128265)
Diffstat (limited to 'Lib/idlelib/idle_test/test_pathbrowser.py')
-rw-r--r-- | Lib/idlelib/idle_test/test_pathbrowser.py | 67 |
1 files changed, 64 insertions, 3 deletions
diff --git a/Lib/idlelib/idle_test/test_pathbrowser.py b/Lib/idlelib/idle_test/test_pathbrowser.py index 813cbcc..74b716a 100644 --- a/Lib/idlelib/idle_test/test_pathbrowser.py +++ b/Lib/idlelib/idle_test/test_pathbrowser.py @@ -1,11 +1,68 @@ +""" Test idlelib.pathbrowser. +""" + + +import os.path +import pyclbr # for _modules +import sys # for sys.path +from tkinter import Tk + +from test.support import requires import unittest -import os -import sys -import idlelib +from idlelib.idle_test.mock_idle import Func + +import idlelib # for __file__ +from idlelib import browser from idlelib import pathbrowser +from idlelib.tree import TreeNode + class PathBrowserTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = Tk() + cls.root.withdraw() + cls.pb = pathbrowser.PathBrowser(cls.root, _utest=True) + + @classmethod + def tearDownClass(cls): + cls.pb.close() + cls.root.update_idletasks() + cls.root.destroy() + del cls.root, cls.pb + + def test_init(self): + pb = self.pb + eq = self.assertEqual + eq(pb.master, self.root) + eq(pyclbr._modules, {}) + self.assertIsInstance(pb.node, TreeNode) + self.assertIsNotNone(browser.file_open) + + def test_settitle(self): + pb = self.pb + self.assertEqual(pb.top.title(), 'Path Browser') + self.assertEqual(pb.top.iconname(), 'Path Browser') + + def test_rootnode(self): + pb = self.pb + rn = pb.rootnode() + self.assertIsInstance(rn, pathbrowser.PathBrowserTreeItem) + + def test_close(self): + pb = self.pb + pb.top.destroy = Func() + pb.node.destroy = Func() + pb.close() + self.assertTrue(pb.top.destroy.called) + self.assertTrue(pb.node.destroy.called) + del pb.top.destroy, pb.node.destroy + + +class DirBrowserTreeItemTest(unittest.TestCase): + def test_DirBrowserTreeItem(self): # Issue16226 - make sure that getting a sublist works d = pathbrowser.DirBrowserTreeItem('') @@ -16,6 +73,9 @@ class PathBrowserTest(unittest.TestCase): self.assertEqual(d.ispackagedir(dir), True) self.assertEqual(d.ispackagedir(dir + '/Icons'), False) + +class PathBrowserTreeItemTest(unittest.TestCase): + def test_PathBrowserTreeItem(self): p = pathbrowser.PathBrowserTreeItem() self.assertEqual(p.GetText(), 'sys.path') @@ -23,5 +83,6 @@ class PathBrowserTest(unittest.TestCase): self.assertEqual(len(sub), len(sys.path)) self.assertEqual(type(sub[0]), pathbrowser.DirBrowserTreeItem) + if __name__ == '__main__': unittest.main(verbosity=2, exit=False) |