diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -1,6 +1,6 @@ import unittest -from test.support import (run_unittest, TESTFN, skip_unless_symlink, - can_symlink, create_empty_file) +from test.support import (TESTFN, skip_unless_symlink, can_symlink, + create_empty_file) import glob import os import shutil @@ -106,9 +106,29 @@ eq(self.glob('sym2'), [self.norm('sym2')]) -def test_main(): - run_unittest(GlobTests) +class GlobBytesTests(GlobTests): + + 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_glob_directory_with_trailing_slash(self): + # This test doesn't use self.glob/norm, override for bytes. + 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')]) if __name__ == "__main__": - test_main() + unittest.main()