1071
1070
if sys.platform == 'win32':
1072
1071
raise tests.TestNotApplicable(
1073
1072
"readdir IOError not tested on win32")
1074
self.requireFeature(features.not_running_as_root)
1075
1073
os.mkdir("test-unreadable")
1076
1074
os.chmod("test-unreadable", 0000)
1077
1075
# must chmod it back so that it can be removed
1708
1706
class TestReCompile(tests.TestCase):
1710
def _deprecated_re_compile_checked(self, *args, **kwargs):
1711
return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
1712
osutils.re_compile_checked, *args, **kwargs)
1714
1708
def test_re_compile_checked(self):
1715
r = self._deprecated_re_compile_checked(r'A*', re.IGNORECASE)
1709
r = osutils.re_compile_checked(r'A*', re.IGNORECASE)
1716
1710
self.assertTrue(r.match('aaaa'))
1717
1711
self.assertTrue(r.match('aAaA'))
1719
1713
def test_re_compile_checked_error(self):
1720
1714
# like https://bugs.launchpad.net/bzr/+bug/251352
1722
# Due to possible test isolation error, re.compile is not lazy at
1723
# this point. We re-install lazy compile.
1724
lazy_regex.install_lazy_compile()
1725
1715
err = self.assertRaises(
1726
1716
errors.BzrCommandError,
1727
self._deprecated_re_compile_checked, '*', re.IGNORECASE, 'test case')
1717
osutils.re_compile_checked, '*', re.IGNORECASE, 'test case')
1728
1718
self.assertEqual(
1729
'Invalid regular expression in test case: '
1730
'"*" nothing to repeat',
1719
"Invalid regular expression in test case: '*': "
1720
"nothing to repeat",
2077
2067
def test_unicode_user(self):
2078
2068
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())
2069
osutils.set_or_unset_env('LOGNAME', u'jrandom\xb6'.encode(ue))
2070
self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())