/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils_encodings.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-23 01:17:27 UTC
  • mfrom: (4165.3.2 ec2-ubuntu)
  • Revision ID: pqm@pqm.ubuntu.com-20090323011727-b4nl10tcxfo4jiwb
(robertc) Various tweaks to ec2 stuff,
        and make it less windows only. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for the osutils wrapper."""
18
18
 
75
75
 
76
76
    def setUp(self):
77
77
        TestCase.setUp(self)
78
 
        self.overrideAttr(sys, 'stdin')
79
 
        self.overrideAttr(sys, 'stdout')
80
 
        self.overrideAttr(sys, 'stderr')
81
 
        self.overrideAttr(osutils, '_cached_user_encoding')
 
78
        self._stdout = sys.stdout
 
79
        self._stderr = sys.stderr
 
80
        self._stdin = sys.stdin
 
81
        self._user_encoding = osutils._cached_user_encoding
 
82
 
 
83
        self.addCleanup(self._reset)
82
84
 
83
85
    def make_wrapped_streams(self,
84
86
                             stdout_encoding,
98
100
            fake_codec.add(stderr_encoding)
99
101
            fake_codec.add(stdin_encoding)
100
102
 
 
103
    def _reset(self):
 
104
        sys.stdout = self._stdout
 
105
        sys.stderr = self._stderr
 
106
        sys.stdin = self._stdin
 
107
        osutils._cached_user_encoding = self._user_encoding
 
108
 
101
109
    def test_get_terminal_encoding(self):
102
110
        self.make_wrapped_streams('stdout_encoding',
103
111
                                  'stderr_encoding',
150
158
 
151
159
    def setUp(self):
152
160
        TestCase.setUp(self)
153
 
        self.overrideAttr(locale, 'getpreferredencoding')
154
 
        self.addCleanup(osutils.set_or_unset_env,
155
 
                        'LANG', os.environ.get('LANG'))
156
 
        self.overrideAttr(sys, 'stderr', StringIOWrapper())
 
161
        self._stderr = sys.stderr
 
162
        self._getpreferredencoding = locale.getpreferredencoding
 
163
        self.addCleanup(self._reset)
 
164
        sys.stderr = StringIOWrapper()
 
165
        # save $LANG
 
166
        self._LANG = os.environ.get('LANG')
 
167
 
 
168
    def _reset(self):
 
169
        locale.getpreferredencoding = self._getpreferredencoding
 
170
        sys.stderr = self._stderr
 
171
        # restore $LANG
 
172
        osutils.set_or_unset_env('LANG', self._LANG)
157
173
 
158
174
    def test_get_user_encoding(self):
159
175
        def f():