1072
1071
if sys.platform == 'win32':
1073
1072
raise tests.TestNotApplicable(
1074
1073
"readdir IOError not tested on win32")
1074
self.requireFeature(features.not_running_as_root)
1075
1075
os.mkdir("test-unreadable")
1076
1076
os.chmod("test-unreadable", 0000)
1077
1077
# must chmod it back so that it can be removed
2077
2077
def test_unicode_user(self):
2078
2078
ue = osutils.get_user_encoding()
2079
uni_val, env_val = tests.probe_unicode_in_user_encoding()
2081
raise tests.TestSkipped(
2082
'Cannot find a unicode character that works in encoding %s'
2083
% (osutils.get_user_encoding(),))
2084
uni_username = u'jrandom' + uni_val
2085
encoded_username = uni_username.encode(ue)
2086
osutils.set_or_unset_env('LOGNAME', encoded_username)
2087
self.assertEqual(uni_username, osutils.getuser_unicode())
2079
2088
osutils.set_or_unset_env('LOGNAME', u'jrandom\xb6'.encode(ue))
2080
2089
self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
2091
class TestBackupNames(tests.TestCase):
2094
super(TestBackupNames, self).setUp()
2097
def backup_exists(self, name):
2098
return name in self.backups
2100
def available_backup_name(self, name):
2101
backup_name = osutils.available_backup_name(name, self.backup_exists)
2102
self.backups.append(backup_name)
2105
def assertBackupName(self, expected, name):
2106
self.assertEqual(expected, self.available_backup_name(name))
2108
def test_empty(self):
2109
self.assertBackupName('file.~1~', 'file')
2111
def test_existing(self):
2112
self.available_backup_name('file')
2113
self.available_backup_name('file')
2114
self.assertBackupName('file.~3~', 'file')
2115
# Empty slots are found, this is not a strict requirement and may be
2116
# revisited if we test against all implementations.
2117
self.backups.remove('file.~2~')
2118
self.assertBackupName('file.~2~', 'file')