/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 breezy/tests/test_osutils_encodings.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from .. import (
24
24
    osutils,
25
25
    )
 
26
from ..sixish import PY3
26
27
from . import (
27
28
    TestCase,
28
29
    )
87
88
                             stdin_encoding,
88
89
                             user_encoding='user_encoding',
89
90
                             enable_fake_encodings=True):
90
 
        sys.stdout = StringIOWithEncoding()
 
91
        if PY3:
 
92
            sys.stdout = StringIOWithEncoding()
 
93
        else:
 
94
            sys.stdout = BytesIOWithEncoding()
91
95
        sys.stdout.encoding = stdout_encoding
92
 
        sys.stderr = StringIOWithEncoding()
 
96
        if PY3:
 
97
            sys.stderr = StringIOWithEncoding()
 
98
        else:
 
99
            sys.stderr = BytesIOWithEncoding()
93
100
        sys.stderr.encoding = stderr_encoding
94
 
        sys.stdin = StringIOWithEncoding()
 
101
        if PY3:
 
102
            sys.stdin = StringIOWithEncoding()
 
103
        else:
 
104
            sys.stdin = BytesIOWithEncoding()
95
105
        sys.stdin.encoding = stdin_encoding
96
106
        osutils._cached_user_encoding = user_encoding
97
107
        if enable_fake_encodings:
174
184
        self.overrideAttr(osutils, '_cached_user_encoding', None)
175
185
        self.overrideAttr(locale, 'getpreferredencoding', self.get_encoding)
176
186
        self.overrideAttr(locale, 'CODESET', None)
177
 
        self.overrideAttr(sys, 'stderr', StringIOWithEncoding())
 
187
        if PY3:
 
188
            self.overrideAttr(sys, 'stderr', StringIOWithEncoding())
 
189
        else:
 
190
            self.overrideAttr(sys, 'stderr', BytesIOWithEncoding())
178
191
 
179
192
    def get_encoding(self, do_setlocale=True):
180
193
        return self._encoding