[Python-checkins] cpython (2.7): Issue #20792: Expand idle_test.test_pathbowser. Tweak file.
terry.reedy
python-checkins at python.org
Mon Jul 20 23:46:15 CEST 2015
https://hg.python.org/cpython/rev/61d7e6fe0003
changeset: 96966:61d7e6fe0003
branch: 2.7
parent: 96959:d248702feab0
user: Terry Jan Reedy <tjreedy at udel.edu>
date: Mon Jul 20 17:44:55 2015 -0400
summary:
Issue #20792: Expand idle_test.test_pathbowser. Tweak file.
Original patch by Saimadhav Heblikar.
files:
Lib/idlelib/PathBrowser.py | 5 +-
Lib/idlelib/idle_test/test_pathbrowser.py | 18 ++++++++++-
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/Lib/idlelib/PathBrowser.py b/Lib/idlelib/PathBrowser.py
--- a/Lib/idlelib/PathBrowser.py
+++ b/Lib/idlelib/PathBrowser.py
@@ -17,6 +17,7 @@
self.init(flist)
def settitle(self):
+ "Set window titles."
self.top.wm_title("Path Browser")
self.top.wm_iconname("Path Browser")
@@ -70,7 +71,7 @@
def ispackagedir(self, file):
if not os.path.isdir(file):
- return 0
+ return False
init = os.path.join(file, "__init__.py")
return os.path.exists(init)
@@ -91,7 +92,7 @@
sorted.sort()
return sorted
-def _path_browser(parent):
+def _path_browser(parent): # htest #
flist = PyShellFileList(parent)
PathBrowser(flist, _htest=True)
parent.mainloop()
diff --git a/Lib/idlelib/idle_test/test_pathbrowser.py b/Lib/idlelib/idle_test/test_pathbrowser.py
--- a/Lib/idlelib/idle_test/test_pathbrowser.py
+++ b/Lib/idlelib/idle_test/test_pathbrowser.py
@@ -1,5 +1,8 @@
import unittest
-import idlelib.PathBrowser as PathBrowser
+import os
+import sys
+import idlelib
+from idlelib import PathBrowser
class PathBrowserTest(unittest.TestCase):
@@ -7,6 +10,19 @@
# Issue16226 - make sure that getting a sublist works
d = PathBrowser.DirBrowserTreeItem('')
d.GetSubList()
+ self.assertEqual('', d.GetText())
+
+ dir = os.path.split(os.path.abspath(idlelib.__file__))[0]
+ self.assertEqual(d.ispackagedir(dir), True)
+ self.assertEqual(d.ispackagedir(dir + '/Icons'), False)
+
+ def test_PathBrowserTreeItem(self):
+ p = PathBrowser.PathBrowserTreeItem()
+ self.assertEqual(p.GetText(), 'sys.path')
+ sub = p.GetSubList()
+ self.assertEqual(len(sub), len(sys.path))
+ # Following fails in 2.7 because old-style class
+ #self.assertEqual(type(sub[0]), PathBrowser.DirBrowserTreeItem)
if __name__ == '__main__':
unittest.main(verbosity=2, exit=False)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list