~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils_encodings.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

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'