~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils_encodings.py

  • Committer: Martin Packman
  • Date: 2011-12-02 13:36:43 UTC
  • mto: This revision was merged to the branch mainline in revision 6344.
  • Revision ID: martin.packman@canonical.com-20111202133643-0j1f9botvq8d61ar
Add get_message_encoding() for use in decoding system messages

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for the osutils wrapper."""
18
18
 
19
19
import codecs
 
20
import errno
20
21
import locale
 
22
import os
21
23
import sys
22
24
 
23
25
from bzrlib import (
221
223
                          '  doesn\'t support the locale set by $LANG (BOGUS)\n'
222
224
                          '  Continuing with ascii encoding.\n',
223
225
                          sys.stderr.getvalue())
 
226
 
 
227
 
 
228
class TestMessageEncoding(TestCase):
 
229
    """Tests for getting the encoding used by system messages"""
 
230
 
 
231
    def test_get_message_encoding(self):
 
232
        encoding_name = osutils.get_message_encoding()
 
233
        "".decode(encoding_name) # should be a valid encoding name
 
234
 
 
235
    def test_get_message_encoding_decodes_strerror(self):
 
236
        encoding_name = osutils.get_message_encoding()
 
237
        for number, name in errno.errorcode.iteritems():
 
238
            string = os.strerror(number)
 
239
            string.decode(encoding_name)