mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-01 00:45:52 +00:00
Fix for Magic Folder tests if the I/O encoding is borked on Unicode platforms (OS X, Windows).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
fc1832d4a1
commit
4d18425ed4
@ -22,8 +22,8 @@ from allmydata import uri
|
||||
class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
def setUp(self):
|
||||
GridTestMixin.setUp(self)
|
||||
self.alice_nickname = self.unicode_or_fallback(u"Alice\u00F8", u"Alice")
|
||||
self.bob_nickname = self.unicode_or_fallback(u"Bob\u00F8", u"Bob")
|
||||
self.alice_nickname = self.unicode_or_fallback(u"Alice\u00F8", u"Alice", io_as_well=True)
|
||||
self.bob_nickname = self.unicode_or_fallback(u"Bob\u00F8", u"Bob", io_as_well=True)
|
||||
|
||||
def do_create_magic_folder(self, client_num):
|
||||
d = self.do_cli("magic-folder", "create", "magic:", client_num=client_num)
|
||||
|
@ -8,7 +8,8 @@ from twisted.trial import unittest
|
||||
|
||||
from allmydata.util import fileutil, log
|
||||
from ..util.assertutil import precondition
|
||||
from allmydata.util.encodingutil import unicode_platform, get_filesystem_encoding
|
||||
from allmydata.util.encodingutil import (unicode_platform, get_filesystem_encoding,
|
||||
get_io_encoding)
|
||||
from ..scripts import runner
|
||||
|
||||
def skip_if_cannot_represent_filename(u):
|
||||
@ -95,14 +96,20 @@ class NonASCIIPathMixin:
|
||||
self.addCleanup(_cleanup)
|
||||
os.mkdir(dirpath)
|
||||
|
||||
def unicode_or_fallback(self, unicode_name, fallback_name):
|
||||
if unicode_platform():
|
||||
return unicode_name
|
||||
try:
|
||||
unicode_name.encode(get_filesystem_encoding())
|
||||
return unicode_name
|
||||
except UnicodeEncodeError:
|
||||
return fallback_name
|
||||
def unicode_or_fallback(self, unicode_name, fallback_name, io_as_well=False):
|
||||
if not unicode_platform():
|
||||
try:
|
||||
unicode_name.encode(get_filesystem_encoding())
|
||||
except UnicodeEncodeError:
|
||||
return fallback_name
|
||||
|
||||
if io_as_well:
|
||||
try:
|
||||
unicode_name.encode(get_io_encoding())
|
||||
except UnicodeEncodeError:
|
||||
return fallback_name
|
||||
|
||||
return unicode_name
|
||||
|
||||
|
||||
class SignalMixin:
|
||||
|
Loading…
x
Reference in New Issue
Block a user