Exemplo n.º 1
0
    def test_glob_literal(self):
        eq = self.assertSequencesEqual_noorder
        eq(self.glob('a'), [self.norm('a')])
        eq(self.glob('a', 'D'), [self.norm('a', 'D')])
        eq(self.glob('aab'), [self.norm('aab')])
        eq(self.glob('zymurgy'), [])

        # test return types are unicode, but only if os.listdir
        # returns unicode filenames
        uniset = set([str])
        tmp = os.listdir('.')
        if set(type(x) for x in tmp) == uniset:
            u1 = glob.glob('*')
            u2 = glob.glob('./*')
            self.assertEqual(set(type(r) for r in u1), uniset)
            self.assertEqual(set(type(r) for r in u2), uniset)
Exemplo n.º 2
0
 def test_glob_directory_with_trailing_slash(self):
     # We are verifying that when there is wildcard pattern which
     # ends with os.sep doesn't blow up.
     res = glob.glob(self.tempdir + '*' + os.sep)
     self.assertEqual(len(res), 1)
     # either of these results are reasonable
     self.assertTrue(res[0] in [self.tempdir, self.tempdir + os.sep])
Exemplo n.º 3
0
 def test_glob_directory_with_trailing_slash(self):
     # We are verifying that when there is wildcard pattern which
     # ends with os.sep doesn't blow up.
     res = glob.glob(self.tempdir + '*' + os.sep)
     self.assertEqual(len(res), 1)
     # either of these results are reasonable
     self.assertTrue(res[0] in [self.tempdir, self.tempdir + os.sep])
Exemplo n.º 4
0
    def test_glob_literal(self):
        eq = self.assertSequencesEqual_noorder
        eq(self.glob('a'), [self.norm('a')])
        eq(self.glob('a', 'D'), [self.norm('a', 'D')])
        eq(self.glob('aab'), [self.norm('aab')])
        eq(self.glob('zymurgy'), [])

        # test return types are unicode, but only if os.listdir
        # returns unicode filenames
        uniset = set([str])
        tmp = os.listdir('.')
        if set(type(x) for x in tmp) == uniset:
            u1 = glob.glob('*')
            u2 = glob.glob('./*')
            self.assertEquals(set(type(r) for r in u1), uniset)
            self.assertEquals(set(type(r) for r in u2), uniset)
Exemplo n.º 5
0
 def glob(self, *parts):
     if len(parts) == 1:
         pattern = parts[0]
     else:
         pattern = os.path.join(*parts)
     p = os.path.join(self.tempdir, pattern)
     res = glob.glob(p)
     self.assertEqual(list(glob.iglob(p)), res)
     return res
Exemplo n.º 6
0
 def glob(self, *parts):
     if len(parts) == 1:
         pattern = parts[0]
     else:
         pattern = os.path.join(*parts)
     p = os.path.join(self.tempdir, pattern)
     res = glob.glob(p)
     self.assertEqual(list(glob.iglob(p)), res)
     return res