Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(864)

Unified Diff: Lib/test/test_glob.py

Issue 13968: Add a recursive function to the glob package
Patch Set: Created 1 year ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Lib/glob.py ('K') | « Lib/glob.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_glob.py Fri Apr 20 18:04:03 2012 -0400
+++ b/Lib/test/test_glob.py Wed Apr 25 13:11:07 2012 +0300
@@ -25,6 +25,7 @@
self.mktemp('ZZZ')
self.mktemp('a', 'bcd', 'EF')
self.mktemp('a', 'bcd', 'efg', 'ha')
+ self.mktemp('r', 'EF')
if can_symlink():
os.symlink(self.norm('broken'), self.norm('sym1'))
os.symlink(self.norm('broken'), self.norm('sym2'))
@@ -105,6 +106,44 @@
eq(self.glob('sym1'), [self.norm('sym1')])
eq(self.glob('sym2'), [self.norm('sym2')])
+ def test_rglob(self):
+ eq = self.assertSequencesEqual_noorder
+ fs = ('aab', 'F'), ('aaa', 'zzzF'), ('a', 'bcd', 'EF'), ('r', 'EF')
+ expected = [os.path.abspath(self.norm(*i)) for i in fs]
+ res = glob.glob(os.path.join(self.tempdir, '**F'))
+ eq(expected, [os.path.abspath(i) for i in res])
+
+ bcds = ('a', 'bcd', 'EF'), ('a', 'bcd', 'efg', 'ha')
+ expected = [os.path.abspath(self.norm(*i)) for i in bcds]
+ pat = os.path.join(self.tempdir, '**/bcd/*')
+ res = glob.glob(pat)
+ eq(expected, [os.path.abspath(i) for i in res])
+
+ expected = []
+ pat = os.path.join(self.tempdir, 'a/**/bcd')
+ res = glob.glob(pat)
+ eq(expected, [os.path.abspath(i) for i in res])
+
+ predir = os.path.abspath(os.curdir)
+ try:
+ os.chdir(self.norm('.'))
+ expected = [os.path.join('aaa', 'zzzF')]
+ res = glob.glob('**zz*F')
+ eq(expected, res)
+
+ efs = ('r', 'EF'), ('a', 'bcd', 'EF')
+ expected = [os.path.join(*i) for i in efs]
+ res = glob.glob('**EF')
+ eq(expected, res)
+
+ # shouldn't be yielded: deep = os.path.join('a', 'bcd', 'efg', 'ha')
+ expected = []
+ res = glob.glob('*efg/ha')
+ eq(expected, res)
+ finally:
+ os.chdir(predir)
+
+
def test_main():
run_unittest(GlobTests)
« Lib/glob.py ('K') | « Lib/glob.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7