~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-12-03 00:17:53 UTC
  • mfrom: (4852.2.1 bzr-fix-publishing)
  • Revision ID: pqm@pqm.ubuntu.com-20091203001753-rrgwdoyxoojmn504
(David Roberts) Doc: delete unnecessary push of a checkout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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():