/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_osutils.py

  • Committer: Jelmer Vernooij
  • Date: 2020-05-24 00:42:36 UTC
  • mto: This revision was merged to the branch mainline in revision 7505.
  • Revision ID: jelmer@jelmer.uk-20200524004236-jdj6obo4k5lznqw2
Cleanup Windows functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2137
2137
        self.assertEqual(self.gid, s.st_gid)
2138
2138
 
2139
2139
 
2140
 
class TestPathFromEnviron(tests.TestCase):
2141
 
 
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)
2147
 
 
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)
2153
 
 
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'))
2164
 
 
2165
 
 
2166
2140
class TestGetHomeDir(tests.TestCase):
2167
2141
 
2168
2142
    def test_is_unicode(self):
2282
2256
            osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)
2283
2257
 
2284
2258
 
2285
 
class TestEnvironmentErrors(tests.TestCase):
2286
 
    """Test handling of environmental errors"""
2287
 
 
2288
 
    def test_is_oserror(self):
2289
 
        self.assertTrue(osutils.is_environment_error(
2290
 
            OSError(errno.EINVAL, "Invalid parameter")))
2291
 
 
2292
 
    def test_is_ioerror(self):
2293
 
        self.assertTrue(osutils.is_environment_error(
2294
 
            IOError(errno.EINVAL, "Invalid parameter")))
2295
 
 
2296
 
    def test_is_socket_error(self):
2297
 
        self.assertTrue(osutils.is_environment_error(
2298
 
            socket.error(errno.EINVAL, "Invalid parameter")))
2299
 
 
2300
 
    def test_is_select_error(self):
2301
 
        self.assertTrue(osutils.is_environment_error(
2302
 
            select.error(errno.EINVAL, "Invalid parameter")))
2303
 
 
2304
 
    def test_is_pywintypes_error(self):
2305
 
        self.requireFeature(features.pywintypes)
2306
 
        import pywintypes
2307
 
        self.assertTrue(osutils.is_environment_error(
2308
 
            pywintypes.error(errno.EINVAL, "Invalid parameter", "Caller")))
2309
 
 
2310
 
 
2311
2259
class SupportsExecutableTests(tests.TestCaseInTempDir):
2312
2260
 
2313
2261
    def test_returns_bool(self):