1
# Copyright (C) 2006-2011 Canonical Ltd
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
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
144
144
self.assertEqual('latin-1', osutils.get_terminal_encoding())
147
self.assertEquals('', sys.stderr.getvalue())
147
self.assertEqual('', sys.stderr.getvalue())
149
149
def test_terminal_cp_unknown(self):
150
150
# test against really unknown encoding
158
158
self.assertEqual('latin-1', osutils.get_terminal_encoding())
161
self.assertEquals('bzr: warning: unknown terminal encoding cp-unknown.\n'
161
self.assertEqual('bzr: warning: unknown terminal encoding cp-unknown.\n'
162
162
' Using encoding latin-1 instead.\n',
163
163
sys.stderr.getvalue())
179
179
def test_get_user_encoding(self):
180
180
self._encoding = 'user_encoding'
181
181
fake_codec.add('user_encoding')
182
self.assertEquals('iso8859-1', # fake_codec maps to latin-1
182
self.assertEqual('iso8859-1', # fake_codec maps to latin-1
183
183
osutils.get_user_encoding())
184
self.assertEquals('', sys.stderr.getvalue())
184
self.assertEqual('', sys.stderr.getvalue())
186
186
def test_user_cp0(self):
187
187
self._encoding = 'cp0'
188
self.assertEquals('ascii', osutils.get_user_encoding())
189
self.assertEquals('', sys.stderr.getvalue())
188
self.assertEqual('ascii', osutils.get_user_encoding())
189
self.assertEqual('', sys.stderr.getvalue())
191
191
def test_user_cp_unknown(self):
192
192
self._encoding = 'cp-unknown'
193
self.assertEquals('ascii', osutils.get_user_encoding())
194
self.assertEquals('bzr: warning: unknown encoding cp-unknown.'
193
self.assertEqual('ascii', osutils.get_user_encoding())
194
self.assertEqual('bzr: warning: unknown encoding cp-unknown.'
195
195
' Continuing with ascii encoding.\n',
196
196
sys.stderr.getvalue())
198
198
def test_user_empty(self):
199
199
"""Running bzr from a vim script gives '' for a preferred locale"""
200
200
self._encoding = ''
201
self.assertEquals('ascii', osutils.get_user_encoding())
202
self.assertEquals('', sys.stderr.getvalue())
201
self.assertEqual('ascii', osutils.get_user_encoding())
202
self.assertEqual('', sys.stderr.getvalue())