~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils_encodings.py

  • Committer: Andrew Bennetts
  • Date: 2011-02-07 04:14:29 UTC
  • mfrom: (5535.4.26 fetch-all-tags-309682)
  • mto: This revision was merged to the branch mainline in revision 5648.
  • Revision ID: andrew.bennetts@canonical.com-20110207041429-3kc1blj34rvvxod9
Merge fetch-all-tags-309682.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-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 codecs
20
20
import locale
21
 
import os
22
21
import sys
23
22
 
24
23
from bzrlib import (
25
 
    errors,
26
24
    osutils,
27
25
    )
28
26
from bzrlib.tests import (
171
169
    def setUp(self):
172
170
        TestCase.setUp(self)
173
171
        self.overrideAttr(locale, 'getpreferredencoding')
174
 
        self.addCleanup(osutils.set_or_unset_env,
175
 
                        'LANG', os.environ.get('LANG'))
176
172
        self.overrideAttr(sys, 'stderr', StringIOWrapper())
177
173
 
178
174
    def test_get_user_encoding(self):
181
177
 
182
178
        locale.getpreferredencoding = f
183
179
        fake_codec.add('user_encoding')
184
 
        self.assertEquals('user_encoding', osutils.get_user_encoding(use_cache=False))
 
180
        self.assertEquals('user_encoding',
 
181
                          osutils.get_user_encoding(use_cache=False))
185
182
        self.assertEquals('', sys.stderr.getvalue())
186
183
 
187
184
    def test_user_cp0(self):
216
213
            raise locale.Error, 'unsupported locale'
217
214
 
218
215
        locale.getpreferredencoding = f
219
 
        os.environ['LANG'] = 'BOGUS'
 
216
        self.overrideEnv('LANG', 'BOGUS')
220
217
        self.assertEquals('ascii', osutils.get_user_encoding(use_cache=False))
221
218
        self.assertEquals('bzr: warning: unsupported locale\n'
222
219
                          '  Could not determine what text encoding to use.\n'