From: Francois Deppierraz Date: Thu, 20 May 2010 08:44:47 +0000 (-0700) Subject: test_cli.py: Fix tests when sys.stdout.encoding=None and refactor this code into... X-Git-Url: https://git.rkrishnan.org/pf/COPYING.TGPPL.html?a=commitdiff_plain;h=6c70fb7b3ca9fbdf0f96832de7601f07bf9ca2ea;p=tahoe-lafs%2Ftahoe-lafs.git test_cli.py: Fix tests when sys.stdout.encoding=None and refactor this code into functions --- diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 2451e105..539d34c2 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -32,6 +32,13 @@ from allmydata.util.stringutils import listdir_unicode, open_unicode, \ timeout = 480 # deep_check takes 360s on Zandr's linksys box, others take > 240s +def skip_non_unicode_fs(): + if sys.getfilesystemencoding() not in ('UTF-8', 'mbcs'): + raise unittest.SkipTest("Arbitrary filenames are not supported by this platform") + +def skip_non_unicode_stdout(): + if not sys.stdout.encoding or sys.stdout.encoding not in ('UTF-8'): + raise unittest.SkipTest("Arbitrary command-line arguments (argv) are not supported by this platform") class CLI(unittest.TestCase): # this test case only looks at argument-processing and simple stuff. @@ -630,11 +637,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): def test_create_unicode(self): - if sys.getfilesystemencoding() not in ('UTF-8', 'mbcs'): - raise unittest.SkipTest("Arbitrary filenames are not supported by this platform") - - if sys.stdout.encoding not in ('UTF-8'): - raise unittest.SkipTest("Arbitrary command-line arguments (argv) are not supported by this platform") + skip_non_unicode_fs() + skip_non_unicode_stdout() self.basedir = "cli/CreateAlias/create_unicode" self.set_up_grid() @@ -967,8 +971,7 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase): def test_immutable_from_file_unicode(self): - if sys.stdout.encoding not in ('UTF-8'): - raise unittest.SkipTest("Arbitrary command-line arguments (argv) are not supported by this platform") + skip_non_unicode_stdout() # tahoe put file.txt "à trier.txt" self.basedir = os.path.dirname(self.mktemp()) @@ -1281,11 +1284,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase): o.parseOptions, ["onearg"]) def test_unicode_filename(self): - if sys.getfilesystemencoding() not in ('UTF-8', 'mbcs'): - raise unittest.SkipTest("Arbitrary filenames are not supported by this platform") - - if sys.stdout.encoding not in ('UTF-8'): - raise unittest.SkipTest("Arbitrary command-line arguments (argv) are not supported by this platform") + skip_non_unicode_fs() + skip_non_unicode_stdout() self.basedir = "cli/Cp/unicode_filename" self.set_up_grid()