~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_win32utils.py

(gz) Fix deprecations of win32utils path function unicode wrappers (Martin
 Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib import (
22
22
    osutils,
 
23
    symbol_versioning,
23
24
    tests,
24
25
    win32utils,
25
26
    )
187
188
        self.assertEquals('not-existing', p)
188
189
 
189
190
 
 
191
class TestLocations(TestCase):
 
192
    """Tests for windows specific path and name retrieving functions"""
 
193
 
 
194
    def test__ensure_unicode_deprecated(self):
 
195
        s = "text"
 
196
        u1 = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
 
197
            win32utils._ensure_unicode, s)
 
198
        self.assertEqual(s, u1)
 
199
        self.assertIsInstance(u1, unicode)
 
200
        u2 = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
 
201
            win32utils._ensure_unicode, u1)
 
202
        self.assertIs(u1, u2)
 
203
    
 
204
    def test_appdata_unicode_deprecated(self):
 
205
        self.overrideEnv("APPDATA", "fakepath")
 
206
        s = win32utils.get_appdata_location()
 
207
        u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
 
208
            win32utils.get_appdata_location_unicode)
 
209
        self.assertEqual(s, u)
 
210
        self.assertIsInstance(s, unicode)
 
211
 
 
212
    def test_home_unicode_deprecated(self):
 
213
        s = win32utils.get_home_location()
 
214
        u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
 
215
            win32utils.get_home_location_unicode)
 
216
        self.assertEqual(s, u)
 
217
        self.assertIsInstance(s, unicode)
 
218
 
 
219
    def test_user_unicode_deprecated(self):
 
220
        self.overrideEnv("USERNAME", "alien")
 
221
        s = win32utils.get_user_name()
 
222
        u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
 
223
            win32utils.get_user_name_unicode)
 
224
        self.assertEqual(s, u)
 
225
        self.assertIsInstance(s, unicode)
 
226
 
 
227
    def test_host_unicode_deprecated(self):
 
228
        self.overrideEnv("COMPUTERNAME", "alienbox")
 
229
        s = win32utils.get_host_name()
 
230
        u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
 
231
            win32utils.get_host_name_unicode)
 
232
        self.assertEqual(s, u)
 
233
        self.assertIsInstance(s, unicode)
 
234
 
 
235
 
190
236
class TestLocationsCtypes(TestCase):
191
237
 
192
238
    _test_needs_features = [CtypesFeature]