/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_win32utils.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2011, 2016 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
 
19
19
import os
20
20
 
21
 
from .. import (
 
21
from bzrlib import (
22
22
    osutils,
23
23
    symbol_versioning,
24
24
    tests,
25
25
    win32utils,
26
26
    )
27
 
from . import (
 
27
from bzrlib.tests import (
28
28
    TestCase,
29
29
    TestCaseInTempDir,
30
30
    TestSkipped,
31
31
    )
32
 
from .features import backslashdir_feature
33
 
from ..win32utils import glob_expand, get_app_path
34
 
from . import (
 
32
from bzrlib.tests.features import backslashdir_feature
 
33
from bzrlib.win32utils import glob_expand, get_app_path
 
34
from bzrlib.tests import (
35
35
    features,
36
36
    )
37
37
 
106
106
 
107
107
    def test_case_insensitive_globbing(self):
108
108
        if os.path.normcase("AbC") == "AbC":
109
 
            self.skipTest("Test requires case insensitive globbing function")
 
109
            self.skip("Test requires case insensitive globbing function")
110
110
        self.build_ascii_tree()
111
111
        self._run_testset([
112
112
            [[u'A'], [u'A']],
169
169
        for a in ('iexplore', 'iexplore.exe'):
170
170
            p = get_app_path(a)
171
171
            d, b = os.path.split(p)
172
 
            self.assertEqual('iexplore.exe', b.lower())
173
 
            self.assertNotEqual('', d)
 
172
            self.assertEquals('iexplore.exe', b.lower())
 
173
            self.assertNotEquals('', d)
174
174
 
175
175
    def test_wordpad(self):
176
176
        # typical windows users should have wordpad in the system
180
180
        for a in ('wordpad', 'wordpad.exe'):
181
181
            p = get_app_path(a)
182
182
            d, b = os.path.split(p)
183
 
            self.assertEqual('wordpad.exe', b.lower())
184
 
            self.assertNotEqual('', d)
 
183
            self.assertEquals('wordpad.exe', b.lower())
 
184
            self.assertNotEquals('', d)
185
185
 
186
186
    def test_not_existing(self):
187
187
        p = get_app_path('not-existing')
188
 
        self.assertEqual('not-existing', p)
 
188
        self.assertEquals('not-existing', p)
 
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)
189
234
 
190
235
 
191
236
class TestLocationsCtypes(TestCase):
192
237
 
193
 
    _test_needs_features = [CtypesFeature, features.win32_feature]
 
238
    _test_needs_features = [CtypesFeature]
194
239
 
195
240
    def assertPathsEqual(self, p1, p2):
196
241
        # TODO: The env var values in particular might return the "short"
197
242
        # version (ie, "C:\DOCUME~1\...").  Its even possible the returned
198
243
        # values will differ only by case - handle these situations as we
199
244
        # come across them.
200
 
        self.assertEqual(p1, p2)
 
245
        self.assertEquals(p1, p2)
201
246
 
202
247
    def test_appdata_not_using_environment(self):
203
248
        # Test that we aren't falling back to the environment
313
358
 
314
359
    def test_case_insensitive_globs(self):
315
360
        if os.path.normcase("AbC") == "AbC":
316
 
            self.skipTest("Test requires case insensitive globbing function")
 
361
            self.skip("Test requires case insensitive globbing function")
317
362
        self.build_tree(['a/', 'a/b.c', 'a/c.c', 'a/c.h'])
318
363
        self.assertCommandLine([u'A/b.c'], 'A/B*')
319
364
 
360
405
        try:
361
406
            bytes_val = unicode_val.encode(osutils.get_user_encoding())
362
407
        except UnicodeEncodeError:
363
 
            self.skipTest("Couldn't encode non-ascii string for environ")
 
408
            self.skip("Couldn't encode non-ascii string to place in environ")
364
409
        os.environ["TEST"] = bytes_val
365
410
        self.assertEqual(unicode_val, win32utils.get_environ_unicode("TEST"))
366
411