~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

(gz) Fix bt.test_osutils and bt.test_config windows fallout from recent
 changes (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2097
2097
 
2098
2098
class TestGetuserUnicode(tests.TestCase):
2099
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
 
2100
2111
    def test_ascii_user(self):
2101
 
        self.overrideEnv('LOGNAME', 'jrandom')
 
2112
        self.overrideEnv(self.envvar_to_override(), 'jrandom')
2102
2113
        self.assertEqual(u'jrandom', osutils.getuser_unicode())
2103
2114
 
2104
2115
    def test_unicode_user(self):
2110
2121
                % (osutils.get_user_encoding(),))
2111
2122
        uni_username = u'jrandom' + uni_val
2112
2123
        encoded_username = uni_username.encode(ue)
2113
 
        self.overrideEnv('LOGNAME', encoded_username)
 
2124
        self.overrideEnv(self.envvar_to_override(), encoded_username)
2114
2125
        self.assertEqual(uni_username, osutils.getuser_unicode())
2115
 
        self.overrideEnv('LOGNAME', u'jrandom\xb6'.encode(ue))
2116
 
        self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
2117
2126
 
2118
2127
 
2119
2128
class TestBackupNames(tests.TestCase):