From: david-sarah Date: Mon, 7 Jun 2010 04:32:38 +0000 (-0700) Subject: Unicode fixes for platforms with non-native-Unicode filesystems. X-Git-Url: https://git.rkrishnan.org/vdrive/%22news.html/simplejson/flags/%3C?a=commitdiff_plain;h=65b6f4e3ce4cdf139b7e21c62c46568eb3875996;p=tahoe-lafs%2Ftahoe-lafs.git Unicode fixes for platforms with non-native-Unicode filesystems. --- diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 6419f0a9..9f440b02 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -22,7 +22,7 @@ class VDriveOptions(BaseOptions, usage.Options): ] def postOptions(self): - # FIXME: allow Unicode node-dir + # TODO: allow Unicode node-dir # compute a node-url from the existing options, put in self['node-url'] if self['node-directory']: if sys.platform == 'win32' and self['node-directory'] == '~/.tahoe': diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 76d1f115..55fede26 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -61,7 +61,7 @@ class CLITestMixin(ReallyEqualMixin): try: u.encode(enc) except UnicodeEncodeError: - raise unittest.SkipTest("A non-ASCII filename %r could not be encoded as %s" (u, enc)) + raise unittest.SkipTest("A non-ASCII filename could not be encoded on this platform.") class CLI(CLITestMixin, unittest.TestCase): @@ -464,11 +464,11 @@ class CLI(CLITestMixin, unittest.TestCase): for name in filenames: path = os.path.join(basedir, name) open(path, "wb").close() - except EnvironmentError, e: + except EnvironmentError: # Maybe the OS or Python wouldn't let us create a file at the badly encoded path, # which is entirely reasonable. raise unittest.SkipTest("This test is only applicable to platforms that allow " - "creating files at badly encoded paths.\n%r" % (e,)) + "creating files at badly encoded paths.") self.failUnlessRaises(FilenameEncodingError, listdir_unicode, unicode(basedir)) @@ -663,8 +663,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): try: etudes_arg = u"études".encode(get_argv_encoding()) lumiere_arg = u"lumière.txt".encode(get_argv_encoding()) - except UnicodeEncodeError, e: - raise unittest.SkipTest("A non-ASCII test argument could not be encoded as %s:\n%r" (get_argv_encoding(), e)) + except UnicodeEncodeError: + raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.") d = self.do_cli("create-alias", etudes_arg) def _check_create_unicode((rc, out, err)): @@ -714,6 +714,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): return d + # TODO: test list-aliases, including Unicode + class Ln(GridTestMixin, CLITestMixin, unittest.TestCase): def _create_test_file(self): @@ -989,8 +991,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase): try: a_trier_arg = u"à trier.txt".encode(get_argv_encoding()) - except UnicodeEncodeError, e: - raise unittest.SkipTest("A non-ASCII command argument could not be encoded as %s:\n%r" (get_argv_encoding(), e)) + except UnicodeEncodeError: + raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.") self.skip_if_cannot_represent_filename(u"à trier.txt") @@ -1064,7 +1066,7 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase): def _check1((rc,out,err)): if good_out is None: self.failUnlessReallyEqual(rc, 1) - self.failUnlessIn("could not be encoded", err) + self.failUnlessIn("files whose names could not be converted", err) self.failUnlessReallyEqual(out, "") else: self.failUnlessReallyEqual(rc, 0) @@ -1092,7 +1094,7 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase): def _check4((rc, out, err)): if good_out is None: self.failUnlessReallyEqual(rc, 1) - self.failUnlessIn("could not be encoded", err) + self.failUnlessIn("files whose names could not be converted", err) self.failUnlessReallyEqual(out, "") else: # listing a file (as dir/filename) should have the edge metadata, @@ -1367,8 +1369,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase): try: fn1_arg = fn1.encode(get_argv_encoding()) artonwall_arg = u"Ärtonwall".encode(get_argv_encoding()) - except UnicodeEncodeError, e: - raise unittest.SkipTest("A non-ASCII command argument could not be encoded as %s:\n%r" (get_argv_encoding(), e)) + except UnicodeEncodeError: + raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.") self.skip_if_cannot_represent_filename(fn1) @@ -2391,8 +2393,8 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase): try: motorhead_arg = u"tahoe:Motörhead".encode(get_argv_encoding()) - except UnicodeEncodeError, e: - raise unittest.SkipTest("A non-ASCII command argument could not be encoded as %s:\n%r" (get_argv_encoding(), e)) + except UnicodeEncodeError: + raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.") d = self.do_cli("create-alias", "tahoe") d.addCallback(lambda res: self.do_cli("mkdir", motorhead_arg)) diff --git a/src/allmydata/test/test_stringutils.py b/src/allmydata/test/test_stringutils.py index f3e57bb1..1d833004 100644 --- a/src/allmydata/test/test_stringutils.py +++ b/src/allmydata/test/test_stringutils.py @@ -203,6 +203,12 @@ class StringUtils(ReallyEqualMixin): if 'dirlist' not in dir(self): return + try: + u"test".encode(self.filesystem_encoding) + except UnicodeEncodeError: + raise unittest.SkipTest("This platform does not support the '%s' filesystem encoding " + "that we are testing for the benefit of a different platform.") + mock_listdir.return_value = self.dirlist mock_getfilesystemencoding.return_value = self.filesystem_encoding