/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 bzrlib/tests/test_osutils.py

  • Committer: Martin Packman
  • Date: 2012-02-01 12:32:26 UTC
  • mto: (6437.23.4 2.5)
  • mto: This revision was merged to the branch mainline in revision 6459.
  • Revision ID: martin.packman@canonical.com-20120201123226-eudbx4v8yl0w8q93
Add some similar tests for path_from_environ as well

Show diffs side-by-side

added added

removed removed

Lines of Context:
2095
2095
        self.assertEquals(self.gid, s.st_gid)
2096
2096
 
2097
2097
 
 
2098
class TestPathFromEnviron(tests.TestCase):
 
2099
 
 
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)
 
2105
 
 
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)
 
2111
 
 
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')
 
2124
 
 
2125
 
2098
2126
class TestGetHomeDir(tests.TestCase):
2099
2127
 
2100
2128
    def test_is_unicode(self):