~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils_encodings.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-11-08 13:45:51 UTC
  • mfrom: (5532.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20101108134551-sxvk77ehmegkrwmm
(vila) Fix news entry

Show diffs side-by-side

added added

removed removed

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