2095
2095
self.assertEquals(self.gid, s.st_gid)
2098
class TestPathFromEnviron(tests.TestCase):
2100
def test_is_unicode(self):
2101
self.overrideEnv('BZR_TEST_PATH', './anywhere at all/')
2102
path = osutils.path_from_environ('BZR_TEST_PATH')
2103
self.assertIsInstance(path, unicode)
2104
self.assertEqual(u'./anywhere at all/', path)
2106
def test_posix_path_env_ascii(self):
2107
self.overrideEnv('BZR_TEST_PATH', '/tmp')
2108
home = osutils._posix_path_from_environ('BZR_TEST_PATH')
2109
self.assertIsInstance(home, unicode)
2110
self.assertEqual(u'/tmp', home)
2112
def test_posix_path_env_unicode(self):
2113
self.requireFeature(features.ByteStringNamedFilesystem)
2114
self.overrideEnv('BZR_TEST_PATH', '/home/\xa7test')
2115
self.overrideAttr(osutils, "_fs_enc", "iso8859-1")
2116
self.assertEqual(u'/home/\xa7test',
2117
osutils._posix_path_from_environ('BZR_TEST_PATH'))
2118
osutils._fs_enc = "iso8859-5"
2119
self.assertEqual(u'/home/\u0407test',
2120
osutils._posix_path_from_environ('BZR_TEST_PATH'))
2121
osutils._fs_enc = "utf-8"
2122
self.assertRaises(errors.BadFilenameEncoding,
2123
osutils._posix_path_from_environ, 'BZR_TEST_PATH')
2126
class TestGetHomeDir(tests.TestCase):
2128
def test_is_unicode(self):
2129
home = osutils._get_home_dir()
2130
self.assertIsInstance(home, unicode)
2132
def test_posix_homeless(self):
2133
self.overrideEnv('HOME', None)
2134
home = osutils._get_home_dir()
2135
self.assertIsInstance(home, unicode)
2137
def test_posix_home_ascii(self):
2138
self.overrideEnv('HOME', '/home/test')
2139
home = osutils._posix_get_home_dir()
2140
self.assertIsInstance(home, unicode)
2141
self.assertEqual(u'/home/test', home)
2143
def test_posix_home_unicode(self):
2144
self.requireFeature(features.ByteStringNamedFilesystem)
2145
self.overrideEnv('HOME', '/home/\xa7test')
2146
self.overrideAttr(osutils, "_fs_enc", "iso8859-1")
2147
self.assertEqual(u'/home/\xa7test', osutils._posix_get_home_dir())
2148
osutils._fs_enc = "iso8859-5"
2149
self.assertEqual(u'/home/\u0407test', osutils._posix_get_home_dir())
2150
osutils._fs_enc = "utf-8"
2151
self.assertRaises(errors.BadFilenameEncoding,
2152
osutils._posix_get_home_dir)
2098
2155
class TestGetuserUnicode(tests.TestCase):
2100
2157
def test_is_unicode(self):