From: david-sarah Date: Sat, 19 Jun 2010 02:26:20 +0000 (-0700) Subject: test_backupdb.py: skip test_unicode if we can't represent the test filenames. X-Git-Tag: allmydata-tahoe-1.7.0~9 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags/pb.xhtml?a=commitdiff_plain;h=6b2f99fa9a1f9552ca15767416136dddb512e573;p=tahoe-lafs%2Ftahoe-lafs.git test_backupdb.py: skip test_unicode if we can't represent the test filenames. --- diff --git a/src/allmydata/test/test_backupdb.py b/src/allmydata/test/test_backupdb.py index bf57b9f4..13c86792 100644 --- a/src/allmydata/test/test_backupdb.py +++ b/src/allmydata/test/test_backupdb.py @@ -4,7 +4,8 @@ from StringIO import StringIO from twisted.trial import unittest from allmydata.util import fileutil -from allmydata.util.stringutils import listdir_unicode +from allmydata.util.stringutils import listdir_unicode, get_filesystem_encoding, unicode_platform +from allmydata.util.assertutil import precondition from allmydata.scripts import backupdb class BackupDB(unittest.TestCase): @@ -16,6 +17,16 @@ class BackupDB(unittest.TestCase): raise unittest.SkipTest("sqlite unavailable, skipping test") return bdb + def skip_if_cannot_represent_filename(self, u): + precondition(isinstance(u, unicode)) + + enc = get_filesystem_encoding() + if not unicode_platform(): + try: + u.encode(enc) + except UnicodeEncodeError: + raise unittest.SkipTest("A non-ASCII filename could not be encoded on this platform.") + def test_basic(self): self.basedir = basedir = os.path.join("backupdb", "create") fileutil.make_dirs(basedir) @@ -77,7 +88,7 @@ class BackupDB(unittest.TestCase): def writeto(self, filename, data): - fn = os.path.join(self.basedir, filename) + fn = os.path.join(self.basedir, unicode(filename)) parentdir = os.path.dirname(fn) fileutil.make_dirs(parentdir) fileutil.write(fn, data) @@ -228,6 +239,9 @@ class BackupDB(unittest.TestCase): self.failIf(r.was_created()) def test_unicode(self): + self.skip_if_cannot_represent_filename(u"f\u00f6\u00f6.txt") + self.skip_if_cannot_represent_filename(u"b\u00e5r.txt") + self.basedir = basedir = os.path.join("backupdb", "unicode") fileutil.make_dirs(basedir) dbfile = os.path.join(basedir, "dbfile")