Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_glob.GlobTests Class Reference

List of all members.

Public Member Functions

def norm
def mktemp
def setUp
def tearDown
def glob
def assertSequencesEqual_noorder
def test_glob_literal
def test_glob_one_directory
def test_glob_nested_directory
def test_glob_directory_names
def test_glob_directory_with_trailing_slash
def test_glob_broken_symlinks

Public Attributes

 tempdir

Detailed Description

Definition at line 7 of file test_glob.py.


Member Function Documentation

Definition at line 45 of file test_glob.py.

00045 
00046     def assertSequencesEqual_noorder(self, l1, l2):
00047         self.assertEqual(set(l1), set(l2))

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_glob.GlobTests.glob (   self,
  parts 
)

Definition at line 35 of file test_glob.py.

00035 
00036     def glob(self, *parts):
00037         if len(parts) == 1:
00038             pattern = parts[0]
00039         else:
00040             pattern = os.path.join(*parts)
00041         p = os.path.join(self.tempdir, pattern)
00042         res = glob.glob(p)
00043         self.assertEqual(list(glob.iglob(p)), res)
00044         return res

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_glob.GlobTests.mktemp (   self,
  parts 
)

Definition at line 12 of file test_glob.py.

00012 
00013     def mktemp(self, *parts):
00014         filename = self.norm(*parts)
00015         base, file = os.path.split(filename)
00016         if not os.path.exists(base):
00017             os.makedirs(base)
00018         f = open(filename, 'w')
00019         f.close()

Here is the call graph for this function:

def test.test_glob.GlobTests.norm (   self,
  parts 
)

Definition at line 9 of file test_glob.py.

00009 
00010     def norm(self, *parts):
00011         return os.path.normpath(os.path.join(self.tempdir, *parts))

Here is the caller graph for this function:

Definition at line 20 of file test_glob.py.

00020 
00021     def setUp(self):
00022         self.tempdir = TESTFN+"_dir"
00023         self.mktemp('a', 'D')
00024         self.mktemp('aab', 'F')
00025         self.mktemp('aaa', 'zzzF')
00026         self.mktemp('ZZZ')
00027         self.mktemp('a', 'bcd', 'EF')
00028         self.mktemp('a', 'bcd', 'efg', 'ha')
00029         if can_symlink():
00030             os.symlink(self.norm('broken'), self.norm('sym1'))
00031             os.symlink(self.norm('broken'), self.norm('sym2'))

Here is the caller graph for this function:

Definition at line 32 of file test_glob.py.

00032 
00033     def tearDown(self):
00034         shutil.rmtree(self.tempdir)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 102 of file test_glob.py.

00102 
00103     def test_glob_broken_symlinks(self):
00104         eq = self.assertSequencesEqual_noorder
00105         eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2')])
00106         eq(self.glob('sym1'), [self.norm('sym1')])
00107         eq(self.glob('sym2'), [self.norm('sym2')])
00108 

Here is the call graph for this function:

Definition at line 84 of file test_glob.py.

00084 
00085     def test_glob_directory_names(self):
00086         eq = self.assertSequencesEqual_noorder
00087         eq(self.glob('*', 'D'), [self.norm('a', 'D')])
00088         eq(self.glob('*', '*a'), [])
00089         eq(self.glob('a', '*', '*', '*a'),
00090            [self.norm('a', 'bcd', 'efg', 'ha')])
00091         eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'),
00092                                                    os.path.join('aab', 'F')]))

Here is the call graph for this function:

Definition at line 93 of file test_glob.py.

00093 
00094     def test_glob_directory_with_trailing_slash(self):
00095         # We are verifying that when there is wildcard pattern which
00096         # ends with os.sep doesn't blow up.
00097         res = glob.glob(self.tempdir + '*' + os.sep)
00098         self.assertEqual(len(res), 1)
00099         # either of these results are reasonable
00100         self.assertIn(res[0], [self.tempdir, self.tempdir + os.sep])

Here is the call graph for this function:

Definition at line 48 of file test_glob.py.

00048 
00049     def test_glob_literal(self):
00050         eq = self.assertSequencesEqual_noorder
00051         eq(self.glob('a'), [self.norm('a')])
00052         eq(self.glob('a', 'D'), [self.norm('a', 'D')])
00053         eq(self.glob('aab'), [self.norm('aab')])
00054         eq(self.glob('zymurgy'), [])
00055 
00056         # test return types are unicode, but only if os.listdir
00057         # returns unicode filenames
00058         uniset = set([str])
00059         tmp = os.listdir('.')
00060         if set(type(x) for x in tmp) == uniset:
00061             u1 = glob.glob('*')
00062             u2 = glob.glob('./*')
00063             self.assertEqual(set(type(r) for r in u1), uniset)
00064             self.assertEqual(set(type(r) for r in u2), uniset)

Here is the call graph for this function:

Definition at line 73 of file test_glob.py.

00073 
00074     def test_glob_nested_directory(self):
00075         eq = self.assertSequencesEqual_noorder
00076         if os.path.normcase("abCD") == "abCD":
00077             # case-sensitive filesystem
00078             eq(self.glob('a', 'bcd', 'E*'), [self.norm('a', 'bcd', 'EF')])
00079         else:
00080             # case insensitive filesystem
00081             eq(self.glob('a', 'bcd', 'E*'), [self.norm('a', 'bcd', 'EF'),
00082                                              self.norm('a', 'bcd', 'efg')])
00083         eq(self.glob('a', 'bcd', '*g'), [self.norm('a', 'bcd', 'efg')])

Here is the call graph for this function:

Definition at line 65 of file test_glob.py.

00065 
00066     def test_glob_one_directory(self):
00067         eq = self.assertSequencesEqual_noorder
00068         eq(self.glob('a*'), map(self.norm, ['a', 'aab', 'aaa']))
00069         eq(self.glob('*a'), map(self.norm, ['a', 'aaa']))
00070         eq(self.glob('aa?'), map(self.norm, ['aaa', 'aab']))
00071         eq(self.glob('aa[ab]'), map(self.norm, ['aaa', 'aab']))
00072         eq(self.glob('*q'), [])

Here is the call graph for this function:


Member Data Documentation

Definition at line 21 of file test_glob.py.


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