~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-23 19:08:05 UTC
  • mfrom: (6437.3.20 2.5)
  • mto: This revision was merged to the branch mainline in revision 6450.
  • Revision ID: jelmer@samba.org-20120123190805-hlcuihkt2dep44cw
merge bzr 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1217
1217
        self.requireFeature(UTF8DirReaderFeature)
1218
1218
        self._save_platform_info()
1219
1219
        win32utils.winver = None # Avoid the win32 detection code
1220
 
        osutils._fs_enc = 'UTF-8'
 
1220
        osutils._fs_enc = 'utf-8'
1221
1221
        self.assertDirReaderIs(
1222
1222
            UTF8DirReaderFeature.module.UTF8DirReader)
1223
1223
 
1225
1225
        self.requireFeature(UTF8DirReaderFeature)
1226
1226
        self._save_platform_info()
1227
1227
        win32utils.winver = None # Avoid the win32 detection code
1228
 
        osutils._fs_enc = 'US-ASCII'
1229
 
        self.assertDirReaderIs(
1230
 
            UTF8DirReaderFeature.module.UTF8DirReader)
1231
 
 
1232
 
    def test_force_walkdirs_utf8_fs_ANSI(self):
1233
 
        self.requireFeature(UTF8DirReaderFeature)
1234
 
        self._save_platform_info()
1235
 
        win32utils.winver = None # Avoid the win32 detection code
1236
 
        osutils._fs_enc = 'ANSI_X3.4-1968'
 
1228
        osutils._fs_enc = 'ascii'
1237
1229
        self.assertDirReaderIs(
1238
1230
            UTF8DirReaderFeature.module.UTF8DirReader)
1239
1231
 
1240
1232
    def test_force_walkdirs_utf8_fs_latin1(self):
1241
1233
        self._save_platform_info()
1242
1234
        win32utils.winver = None # Avoid the win32 detection code
1243
 
        osutils._fs_enc = 'latin1'
 
1235
        osutils._fs_enc = 'iso-8859-1'
1244
1236
        self.assertDirReaderIs(osutils.UnicodeDirReader)
1245
1237
 
1246
1238
    def test_force_walkdirs_utf8_nt(self):
2105
2097
 
2106
2098
class TestGetuserUnicode(tests.TestCase):
2107
2099
 
 
2100
    def test_is_unicode(self):
 
2101
        user = osutils.getuser_unicode()
 
2102
        self.assertIsInstance(user, unicode)
 
2103
 
 
2104
    def envvar_to_override(self):
 
2105
        if sys.platform == "win32":
 
2106
            # Disable use of platform calls on windows so envvar is used
 
2107
            self.overrideAttr(win32utils, 'has_ctypes', False)
 
2108
            return 'USERNAME' # only variable used on windows
 
2109
        return 'LOGNAME' # first variable checked by getpass.getuser()
 
2110
 
2108
2111
    def test_ascii_user(self):
2109
 
        self.overrideEnv('LOGNAME', 'jrandom')
 
2112
        self.overrideEnv(self.envvar_to_override(), 'jrandom')
2110
2113
        self.assertEqual(u'jrandom', osutils.getuser_unicode())
2111
2114
 
2112
2115
    def test_unicode_user(self):
2118
2121
                % (osutils.get_user_encoding(),))
2119
2122
        uni_username = u'jrandom' + uni_val
2120
2123
        encoded_username = uni_username.encode(ue)
2121
 
        self.overrideEnv('LOGNAME', encoded_username)
 
2124
        self.overrideEnv(self.envvar_to_override(), encoded_username)
2122
2125
        self.assertEqual(uni_username, osutils.getuser_unicode())
2123
 
        self.overrideEnv('LOGNAME', u'jrandom\xb6'.encode(ue))
2124
 
        self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
2125
 
 
2126
 
    def test_no_username_bug_660174(self):
2127
 
        self.requireFeature(features.win32_feature)
2128
 
        for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
2129
 
            self.overrideEnv(name, None)
2130
 
        self.assertEqual(u'UNKNOWN', osutils.getuser_unicode())
2131
2126
 
2132
2127
 
2133
2128
class TestBackupNames(tests.TestCase):