/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/ui_testing.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
import io
18
20
 
19
21
from .. import (
20
22
    ui,
21
23
)
22
 
from ..ui import text as ui_text
 
24
from ..sixish import (
 
25
    text_type,
 
26
)
23
27
 
24
28
 
25
29
class StringIOWithEncoding(io.StringIO):
44
48
        return True
45
49
 
46
50
 
47
 
class TextUIFactory(ui_text.TextUIFactory):
 
51
class TextUIFactory(ui.text.TextUIFactory):
48
52
 
49
53
    def __init__(self, stdin=None, stdout=None, stderr=None):
50
54
        if isinstance(stdin, bytes):
51
55
            stdin = stdin.decode()
52
 
        if isinstance(stdin, str):
 
56
        if isinstance(stdin, text_type):
53
57
            stdin = StringIOWithEncoding(stdin)
54
58
        if stdout is None:
55
59
            stdout = StringIOWithEncoding()
57
61
            stderr = StringIOWithEncoding()
58
62
        super(TextUIFactory, self).__init__(stdin, stdout, stderr)
59
63
 
60
 
    def _setup_streams(self):
61
 
        self.raw_stdin = self.stdin
62
 
        self.raw_stdout = self.stdout
63
 
        self.raw_stderr = self.stderr
64
 
 
65
64
 
66
65
class TestUIFactory(TextUIFactory):
67
66
    """A UI Factory for testing.