2137
2137
self.assertEqual(self.gid, s.st_gid)
2140
class TestPathFromEnviron(tests.TestCase):
2142
def test_is_unicode(self):
2143
self.overrideEnv('BRZ_TEST_PATH', './anywhere at all/')
2144
path = osutils.path_from_environ('BRZ_TEST_PATH')
2145
self.assertIsInstance(path, str)
2146
self.assertEqual(u'./anywhere at all/', path)
2148
def test_posix_path_env_ascii(self):
2149
self.overrideEnv('BRZ_TEST_PATH', '/tmp')
2150
home = osutils._posix_path_from_environ('BRZ_TEST_PATH')
2151
self.assertIsInstance(home, str)
2152
self.assertEqual(u'/tmp', home)
2154
def test_posix_path_env_unicode(self):
2155
self.requireFeature(features.ByteStringNamedFilesystem)
2156
self.overrideEnv('BRZ_TEST_PATH', '/home/\xa7test')
2157
self.overrideAttr(osutils, "_fs_enc", "iso8859-1")
2158
self.assertEqual(u'/home/\xa7test',
2159
osutils._posix_path_from_environ('BRZ_TEST_PATH'))
2160
osutils._fs_enc = "iso8859-5"
2161
# In Python 3, os.environ returns unicode.
2162
self.assertEqual(u'/home/\xa7test',
2163
osutils._posix_path_from_environ('BRZ_TEST_PATH'))
2166
2140
class TestGetHomeDir(tests.TestCase):
2168
2142
def test_is_unicode(self):
2282
2256
osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)
2285
class TestEnvironmentErrors(tests.TestCase):
2286
"""Test handling of environmental errors"""
2288
def test_is_oserror(self):
2289
self.assertTrue(osutils.is_environment_error(
2290
OSError(errno.EINVAL, "Invalid parameter")))
2292
def test_is_ioerror(self):
2293
self.assertTrue(osutils.is_environment_error(
2294
IOError(errno.EINVAL, "Invalid parameter")))
2296
def test_is_socket_error(self):
2297
self.assertTrue(osutils.is_environment_error(
2298
socket.error(errno.EINVAL, "Invalid parameter")))
2300
def test_is_select_error(self):
2301
self.assertTrue(osutils.is_environment_error(
2302
select.error(errno.EINVAL, "Invalid parameter")))
2304
def test_is_pywintypes_error(self):
2305
self.requireFeature(features.pywintypes)
2307
self.assertTrue(osutils.is_environment_error(
2308
pywintypes.error(errno.EINVAL, "Invalid parameter", "Caller")))
2311
2259
class SupportsExecutableTests(tests.TestCaseInTempDir):
2313
2261
def test_returns_bool(self):