~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: 2009-02-23 17:00:36 UTC
  • mfrom: (4032.1.4 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090223170036-3q1v68ewdt8i0to5
(Marius Kruger) Remove all trailing whitespace and add tests to
        enforce this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    )
28
28
from bzrlib.tests import (
29
29
        StringIOWrapper,
30
 
        TestCase, 
 
30
        TestCase,
31
31
        )
32
32
 
33
33
 
34
34
class FakeCodec(object):
35
35
    """Special class that helps testing over several non-existed encodings.
36
 
    
 
36
 
37
37
    Clients can add new encoding names, but because of how codecs is
38
38
    implemented they cannot be removed. Be careful with naming to avoid
39
39
    collisions between tests.
51
51
            self._registered = True
52
52
        if encoding_name is not None:
53
53
            self._enabled_encodings.add(encoding_name)
54
 
        
 
54
 
55
55
    def __call__(self, encoding_name):
56
56
        """Called indirectly by codecs module during lookup"""
57
57
        if encoding_name in self._enabled_encodings:
62
62
 
63
63
 
64
64
class TestFakeCodec(TestCase):
65
 
    
 
65
 
66
66
    def test_fake_codec(self):
67
67
        self.assertRaises(LookupError, codecs.lookup, 'fake')
68
68
 
81
81
 
82
82
        self.addCleanup(self._reset)
83
83
 
84
 
    def make_wrapped_streams(self, 
 
84
    def make_wrapped_streams(self,
85
85
                             stdout_encoding,
86
86
                             stderr_encoding,
87
87
                             stdin_encoding,
143
143
                                  'cp-unknown',
144
144
                                  user_encoding='latin-1',
145
145
                                  enable_fake_encodings=False)
146
 
        
 
146
 
147
147
        self.assertEqual('latin-1', osutils.get_terminal_encoding())
148
148
 
149
149
        # check stderr
150
150
        self.assertEquals('bzr: warning: unknown terminal encoding cp-unknown.\n'
151
 
                          '  Using encoding latin-1 instead.\n', 
 
151
                          '  Using encoding latin-1 instead.\n',
152
152
                          sys.stderr.getvalue())
153
153
 
154
154
 
155
155
class TestUserEncoding(TestCase):
156
156
    """Test detection of default user encoding."""
157
 
    
 
157
 
158
158
    def setUp(self):
159
159
        self._stderr = sys.stderr
160
160
        self._getpreferredencoding = locale.getpreferredencoding