diff -r d54f047312a8 Lib/test/test_glob.py --- a/Lib/test/test_glob.py Fri Aug 31 11:31:20 2012 -0400 +++ b/Lib/test/test_glob.py Fri Aug 31 22:32:14 2012 +0100 @@ -105,10 +105,34 @@ eq(self.glob('sym1'), [self.norm('sym1')]) eq(self.glob('sym2'), [self.norm('sym2')]) +class GlobBytesTests(GlobTests): + # Overriding self.norm and self.glob to convert their arguments + # into the bytes type, so that the part of glob.glob which deals + # with bytes-type pathnames is tested. + def norm(self, *parts): + return bytes(os.path.normpath(os.path.join( + self.tempdir, *parts)), 'ASCII') + + def glob(self, *parts): + if len(parts) == 1: + pattern = parts[0] + else: + pattern = os.path.join(*parts) + p = bytes(os.path.join(self.tempdir, pattern), 'ASCII') + res = glob.glob(p) + self.assertEqual(list(glob.iglob(p)), res) + return res + + def test_bytes_glob_directory_with_trailing_slash(self): + res = glob.glob(bytes(self.tempdir + '*' + os.sep, 'ASCII')) + self.assertEqual(len(res), 1) + self.assertIn(res[0], [bytes(self.tempdir, 'ASCII'), + bytes(self.tempdir + os.sep, 'ASCII')]) def test_main(): run_unittest(GlobTests) - + run_unittest(GlobBytesTests) + if __name__ == "__main__": test_main()